CURSOR
How do I use C U R S O R
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: ReadmeEditor.cs
Copy
143 bool LinkLabel (GUIContent label, params GUILayoutOption[] options)
144 {
145 var position = GUILayoutUtility.GetRect(label, LinkStyle, options);
146
147 Handles.BeginGUI ();
148 Handles.color = LinkStyle.normal.textColor;
149 Handles.DrawLine (new Vector3(position.xMin, position.yMax), new Vector3(position.xMax, position.yMax));
150 Handles.color = Color.white;
151 Handles.EndGUI ();
152
153 EditorGUIUtility.AddCursorRect (position, MouseCursor.Link);
154
155 return GUI.Button (position, label, LinkStyle);
156 }
File name: frmCustomerOrders.cs
Copy
28 private void Button7_Click(object sender, EventArgs e)
29 {
30 if (DataGridView3.DataSource == null)
31 {
32 MessageBox.Show("Sorry nothing to export into excel sheet..", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
33 return;
34 }
35 int rowsTotal = 0;
36 int colsTotal = 0;
37 int I = 0;
38 int j = 0;
39 int iC = 0;
40 System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
41 Excel.Application xlApp = new Excel.Application();
42
43 try
44 {
45 Excel.Workbook excelBook = xlApp.Workbooks.Add();
46 Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelBook.Worksheets[1];
47 xlApp.Visible = true;
48
49 rowsTotal = DataGridView3.RowCount;
50 colsTotal = DataGridView3.Columns.Count - 1;
51 var _with1 = excelWorksheet;
52 _with1.Cells.Select();
53 _with1.Cells.Delete();
54 for (iC = 0; iC <= colsTotal; iC++)
55 {
56 _with1.Cells[1, iC + 1].Value = DataGridView3.Columns[iC].HeaderText;
57 }
58 for (I = 0; I <= rowsTotal - 1; I++)
59 {
60 for (j = 0; j <= colsTotal; j++)
61 {
62 _with1.Cells[I + 2, j + 1].value = DataGridView3.Rows[I].Cells[j].Value;
63 }
64 }
65 _with1.Rows["1:1"].Font.FontStyle = "Bold";
66 _with1.Rows["1:1"].Font.Size = 12;
67
68 _with1.Cells.Columns.AutoFit();
69 _with1.Cells.Select();
70 _with1.Cells.EntireColumn.AutoFit();
71 _with1.Cells[1, 1].Select();
72 }
73 catch (Exception ex)
74 {
75 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
76 }
77 finally
78 {
79 //RELEASE ALLOACTED RESOURCES
80 System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
81 xlApp = null;
82 }
83 }
File name: frmCustomerOrders.cs
Copy
223 private void Button3_Click(object sender, EventArgs e)
224 {
225 if (DataGridView1.DataSource == null)
226 {
227 MessageBox.Show("Sorry nothing to export into excel sheet..", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
228 return;
229 }
230 int rowsTotal = 0;
231 int colsTotal = 0;
232 int I = 0;
233 int j = 0;
234 int iC = 0;
235 System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
236 Excel.Application xlApp = new Excel.Application();
237
238 try
239 {
240 Excel.Workbook excelBook = xlApp.Workbooks.Add();
241 Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelBook.Worksheets[1];
242 xlApp.Visible = true;
243
244 rowsTotal = DataGridView1.RowCount;
245 colsTotal = DataGridView1.Columns.Count - 1;
246 var _with1 = excelWorksheet;
247 _with1.Cells.Select();
248 _with1.Cells.Delete();
249 for (iC = 0; iC <= colsTotal; iC++)
250 {
251 _with1.Cells[1, iC + 1].Value = DataGridView1.Columns[iC].HeaderText;
252 }
253 for (I = 0; I <= rowsTotal - 1; I++)
254 {
255 for (j = 0; j <= colsTotal; j++)
256 {
257 _with1.Cells[I + 2, j + 1].value = DataGridView1.Rows[I].Cells[j].Value;
258 }
259 }
260 _with1.Rows["1:1"].Font.FontStyle = "Bold";
261 _with1.Rows["1:1"].Font.Size = 12;
262
263 _with1.Cells.Columns.AutoFit();
264 _with1.Cells.Select();
265 _with1.Cells.EntireColumn.AutoFit();
266 _with1.Cells[1, 1].Select();
267 }
268 catch (Exception ex)
269 {
270 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
271 }
272 finally
273 {
274 //RELEASE ALLOACTED RESOURCES
275 System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
276 xlApp = null;
277 }
278 }
File name: frmCustomersRecord.cs
Copy
85 private void Button3_Click(object sender, EventArgs e)
86 {
87 if (dataGridView1.DataSource == null)
88 {
89 MessageBox.Show("Sorry nothing to export into excel sheet..", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
90 return;
91 }
92 int rowsTotal = 0;
93 int colsTotal = 0;
94 int I = 0;
95 int j = 0;
96 int iC = 0;
97 System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
98 Excel.Application xlApp = new Excel.Application();
99
100 try
101 {
102 Excel.Workbook excelBook = xlApp.Workbooks.Add();
103 Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelBook.Worksheets[1];
104 xlApp.Visible = true;
105
106 rowsTotal = dataGridView1.RowCount;
107 colsTotal = dataGridView1.Columns.Count - 1;
108 var _with1 = excelWorksheet;
109 _with1.Cells.Select();
110 _with1.Cells.Delete();
111 for (iC = 0; iC <= colsTotal; iC++)
112 {
113 _with1.Cells[1, iC + 1].Value = dataGridView1.Columns[iC].HeaderText;
114 }
115 for (I = 0; I <= rowsTotal - 1; I++)
116 {
117 for (j = 0; j <= colsTotal; j++)
118 {
119 _with1.Cells[I + 2, j + 1].value = dataGridView1.Rows[I].Cells[j].Value;
120 }
121 }
122 _with1.Rows["1:1"].Font.FontStyle = "Bold";
123 _with1.Rows["1:1"].Font.Size = 12;
124
125 _with1.Cells.Columns.AutoFit();
126 _with1.Cells.Select();
127 _with1.Cells.EntireColumn.AutoFit();
128 _with1.Cells[1, 1].Select();
129 }
130 catch (Exception ex)
131 {
132 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
133 }
134 finally
135 {
136 //RELEASE ALLOACTED RESOURCES
137 System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
138 xlApp = null;
139 }
140 }
File name: frmCustomersRecord.cs
Copy
142 private void button1_Click(object sender, EventArgs e)
143 {
144 try
145 {
146 Cursor = Cursors.WaitCursor;
147 timer1.Enabled = true;
148 rptCustomers rpt = new rptCustomers();
149 //The report you created.
150 frmCustomersReport frm = new frmCustomersReport();
151 SqlConnection myConnection = default(SqlConnection);
152 SqlCommand MyCommand = new SqlCommand();
153 SqlDataAdapter myDA = new SqlDataAdapter();
154 POS_DBDataSet myDS = new POS_DBDataSet();
155 //The DataSet you created.
156 myConnection = new SqlConnection(cs.DBConn);
157 MyCommand.Connection = myConnection;
158 MyCommand.CommandText = "select * from Customer Order by CustomerName";
159 MyCommand.CommandType = CommandType.Text;
160 myDA.SelectCommand = MyCommand;
161 myDA.Fill(myDS, "Customer");
162 rpt.SetDataSource(myDS);
163 frm.crystalReportViewer1.ReportSource = rpt;
164 frm.Show();
165 }
166 catch (Exception ex)
167 {
168 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
169 }
170 }
File name: frmCustomersRecord.cs
Copy
172 private void timer1_Tick(object sender, EventArgs e)
173 {
174
175 Cursor = Cursors.Default;
176 timer1.Enabled = false;
177 }
File name: frmCustomersRecord1.cs
Copy
103 private void Button3_Click(object sender, EventArgs e)
104 {
105 if (dataGridView1.DataSource == null)
106 {
107 MessageBox.Show("Sorry nothing to export into excel sheet..", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
108 return;
109 }
110 int rowsTotal = 0;
111 int colsTotal = 0;
112 int I = 0;
113 int j = 0;
114 int iC = 0;
115 System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
116 Excel.Application xlApp = new Excel.Application();
117
118 try
119 {
120 Excel.Workbook excelBook = xlApp.Workbooks.Add();
121 Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelBook.Worksheets[1];
122 xlApp.Visible = true;
123
124 rowsTotal = dataGridView1.RowCount;
125 colsTotal = dataGridView1.Columns.Count - 1;
126 var _with1 = excelWorksheet;
127 _with1.Cells.Select();
128 _with1.Cells.Delete();
129 for (iC = 0; iC <= colsTotal; iC++)
130 {
131 _with1.Cells[1, iC + 1].Value = dataGridView1.Columns[iC].HeaderText;
132 }
133 for (I = 0; I <= rowsTotal - 1; I++)
134 {
135 for (j = 0; j <= colsTotal; j++)
136 {
137 _with1.Cells[I + 2, j + 1].value = dataGridView1.Rows[I].Cells[j].Value;
138 }
139 }
140 _with1.Rows["1:1"].Font.FontStyle = "Bold";
141 _with1.Rows["1:1"].Font.Size = 12;
142
143 _with1.Cells.Columns.AutoFit();
144 _with1.Cells.Select();
145 _with1.Cells.EntireColumn.AutoFit();
146 _with1.Cells[1, 1].Select();
147 }
148 catch (Exception ex)
149 {
150 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
151 }
152 finally
153 {
154 //RELEASE ALLOACTED RESOURCES
155 System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
156 xlApp = null;
157 }
158 }
File name: frmCustomersRecord2.cs
Copy
110 private void Button3_Click(object sender, EventArgs e)
111 {
112 if (dataGridView1.DataSource == null)
113 {
114 MessageBox.Show("Sorry nothing to export into excel sheet..", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
115 return;
116 }
117 int rowsTotal = 0;
118 int colsTotal = 0;
119 int I = 0;
120 int j = 0;
121 int iC = 0;
122 System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
123 Excel.Application xlApp = new Excel.Application();
124
125 try
126 {
127 Excel.Workbook excelBook = xlApp.Workbooks.Add();
128 Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelBook.Worksheets[1];
129 xlApp.Visible = true;
130
131 rowsTotal = dataGridView1.RowCount;
132 colsTotal = dataGridView1.Columns.Count - 1;
133 var _with1 = excelWorksheet;
134 _with1.Cells.Select();
135 _with1.Cells.Delete();
136 for (iC = 0; iC <= colsTotal; iC++)
137 {
138 _with1.Cells[1, iC + 1].Value = dataGridView1.Columns[iC].HeaderText;
139 }
140 for (I = 0; I <= rowsTotal - 1; I++)
141 {
142 for (j = 0; j <= colsTotal; j++)
143 {
144 _with1.Cells[I + 2, j + 1].value = dataGridView1.Rows[I].Cells[j].Value;
145 }
146 }
147 _with1.Rows["1:1"].Font.FontStyle = "Bold";
148 _with1.Rows["1:1"].Font.Size = 12;
149
150 _with1.Cells.Columns.AutoFit();
151 _with1.Cells.Select();
152 _with1.Cells.EntireColumn.AutoFit();
153 _with1.Cells[1, 1].Select();
154 }
155 catch (Exception ex)
156 {
157 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
158 }
159 finally
160 {
161 //RELEASE ALLOACTED RESOURCES
162 System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
163 xlApp = null;
164 }
165 }
File name: frmMainMenu.cs
Copy
367 private void backupToolStripMenuItem_Click(object sender, EventArgs e)
368 {
369 try
370 {
371 Cursor = Cursors.WaitCursor;
372 timer2.Enabled = true;
373 if ((!System.IO.Directory.Exists("C:\\DBBackup")))
374 {
375 System.IO.Directory.CreateDirectory("C:\\DBBackup");
376 }
377 string destdir = "C:\\DBBackup\\pos_db " + DateTime.Now.ToString("dd-MM-yyyy_HH-mm-ss") + ".bak";
378 con = new SqlConnection(cs.DBConn);
379 con.Open();
380 string cb = "backup database [" + System.Windows.Forms.Application.StartupPath + "\\pos_db.mdf] to disk='" + destdir + "'with init,stats=10";
381 cmd = new SqlCommand(cb);
382 cmd.Connection = con;
383 cmd.ExecuteReader();
384 con.Close();
385 MessageBox.Show("Successfully performed", "Database Backup", MessageBoxButtons.OK, MessageBoxIcon.Information);
386 }
387 catch (Exception ex)
388 {
389 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
390 }
391 }
File name: frmMainMenu.cs
Copy
393 private void restoreToolStripMenuItem_Click(object sender, EventArgs e)
394 {
395 try
396 {
397 var _with1 = openFileDialog1;
398 _with1.Filter = ("DB Backup File|*.bak;");
399 _with1.FilterIndex = 4;
400 //Clear the file name
401 openFileDialog1.FileName = "";
402
403 if (openFileDialog1.ShowDialog() == DialogResult.OK)
404 {
405 Cursor = Cursors.WaitCursor;
406 timer2.Enabled = true;
407 SqlConnection.ClearAllPools();
408 con = new SqlConnection(cs.DBConn);
409 con.Open();
410 string cb = "USE Master ALTER DATABASE [" + System.Windows.Forms.Application.StartupPath + "\\pos_db.mdf] SET Single_User WITH Rollback Immediate Restore database [" + System.Windows.Forms.Application.StartupPath + "\\pos_db.mdf] FROM disk='" + openFileDialog1.FileName + "' WITH REPLACE ALTER DATABASE [" + System.Windows.Forms.Application.StartupPath + "\\pos_db.mdf] SET Multi_User ";
411 cmd = new SqlCommand(cb);
412 cmd.Connection = con;
413 cmd.ExecuteReader();
414 MessageBox.Show("Successfully performed", "Database Restore", MessageBoxButtons.OK, MessageBoxIcon.Information);
415 GetData();
416 }
417 }
418 catch (Exception ex)
419 {
420 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
421 }
422 }
Download file with original file name:CURSOR
CURSOR 180 lượt xem
Gõ tìm kiếm nhanh...