CurrentRow
How do I use Current Row
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: Form1.cs
Copy
347 public void Button6_Click(System.Object sender, System.EventArgs e)
348 {
349
350 TextBox1.Text = DataGridView1.CurrentRow.Cells[1].Value.ToString();
351 TextBox2.Text = DataGridView1.CurrentRow.Cells[2].Value.ToString();
352 TextBox3.Text = DataGridView1.CurrentRow.Cells[3].Value.ToString();
353 TextBox4.Text = DataGridView1.CurrentRow.Cells[4].Value.ToString();
354 TextBox5.Text = DataGridView1.CurrentRow.Cells[5].Value.ToString();
355 TextBox6.Text = DataGridView1.CurrentRow.Cells[6].Value.ToString();
356 TextBox7.Text = DataGridView1.CurrentRow.Cells[7].Value.ToString();
357 TextBox8.Text = DataGridView1.CurrentRow.Cells[8].Value.ToString();
358 TextBox9.Text = DataGridView1.CurrentRow.Cells[9].Value.ToString();
359 TextBox10.Text = DataGridView1.CurrentRow.Cells[10].Value.ToString();
360 TextBox11.Text = DataGridView1.CurrentRow.Cells[11].Value.ToString();
361 TextBox12.Text = DataGridView1.CurrentRow.Cells[12].Value.ToString();
362 TextBox13.Text = DataGridView1.CurrentRow.Cells[13].Value.ToString();
363 TextBox14.Text = DataGridView1.CurrentRow.Cells[14].Value.ToString();
364 TextBox15.Text = DataGridView1.CurrentRow.Cells[15].Value.ToString();
365 TextBox16.Text = DataGridView1.CurrentRow.Cells[16].Value.ToString();
366 TextBox17.Text = DataGridView1.CurrentRow.Cells[17].Value.ToString();
367 TextBox18.Text = DataGridView1.CurrentRow.Cells[18].Value.ToString();
368 TextBox19.Text = DataGridView1.CurrentRow.Cells[19].Value.ToString();
369 STUDID.Text = DataGridView1.CurrentRow.Cells[0].Value.ToString();
370
371 }
File name: FlowLayoutGroup.cs
Copy
99 public float SetLayout(float width, int axis, bool layoutInput)
100 {
101 var groupHeight = rectTransform.rect.height;
102
103 // Width that is available after padding is subtracted
104 var workingWidth = rectTransform.rect.width - padding.left - padding.right;
105
106 // Accumulates the total height of the rows, including spacing and padding.
107 var yOffset = IsLowerAlign ? (float)padding.bottom : (float)padding.top;
108
109 var currentRowWidth = 0f;
110 var currentRowHeight = 0f;
111
112 for (var i = 0; i < rectChildren.Count; i++) {
113
114 // LowerAlign works from back to front
115 var index = IsLowerAlign ? rectChildren.Count - 1 - i : i;
116
117 var child = rectChildren[index];
118
119 var childWidth = LayoutUtility.GetPreferredSize(child, 0);
120 var childHeight = LayoutUtility.GetPreferredSize(child, 1);
121
122 // Max child width is layout group width - padding
123 childWidth = Mathf.Min(childWidth, workingWidth);
124
125 // If adding this element would exceed the bounds of the row,
126 // go to a new line after processing the current row
127 if (currentRowWidth + childWidth > workingWidth) {
128
129 currentRowWidth -= SpacingX;
130
131 // Process current row elements positioning
132 if (!layoutInput) {
133
134 var h = CalculateRowVerticalOffset(groupHeight, yOffset, currentRowHeight);
135 LayoutRow(_rowList, currentRowWidth, currentRowHeight, workingWidth, padding.left, h, axis);
136
137 }
138
139 // Clear existing row
140 _rowList.Clear();
141
142 // Add the current row height to total height accumulator, and reset to 0 for the next row
143 yOffset += currentRowHeight;
144 yOffset += SpacingY;
145
146 currentRowHeight = 0;
147 currentRowWidth = 0;
148
149 }
150
151 currentRowWidth += childWidth;
152 _rowList.Add(child);
153
154 // We need the largest element height to determine the starting position of the next line
155 if (childHeight > currentRowHeight) {
156 currentRowHeight = childHeight;
157 }
158
159 // Don't do this for the last one
160 if (i < rectChildren.Count - 1 )
161 currentRowWidth += SpacingX;
162 }
163
164 if (!layoutInput) {
165 var h = CalculateRowVerticalOffset(groupHeight, yOffset, currentRowHeight);
166 currentRowWidth -= SpacingX;
167 // Layout the final row
168 LayoutRow(_rowList, currentRowWidth, currentRowHeight, workingWidth - (_rowList.Count > 1 ? SpacingX : 0), padding.left, h, axis);
169 }
170
171 _rowList.Clear();
172
173 // Add the last rows height to the height accumulator
174 yOffset += currentRowHeight;
175 yOffset += IsLowerAlign ? padding.top : padding.bottom;
176
177 if (layoutInput) {
178
179 if(axis == 1)
180 SetLayoutInputForAxis(yOffset, yOffset, -1, axis);
181
182 }
183
184 return yOffset;
185 }
File name: FlowLayoutGroup.cs
Copy
187 private float CalculateRowVerticalOffset(float groupHeight, float yOffset, float currentRowHeight)
188 {
189 float h;
190
191 if (IsLowerAlign) {
192 h = groupHeight - yOffset - currentRowHeight;
193 } else if (IsMiddleAlign) {
194 h = groupHeight*0.5f - _layoutHeight * 0.5f + yOffset;
195 } else {
196 h = yOffset;
197 }
198 return h;
199 }
File name: frmItems.cs
Copy
138 private void btndelete_Click(object sender, EventArgs e)
139 {
140 sql = "DELETE FROM tblitems WHERE ITEMID='" + dtglist.CurrentRow.Cells[0].Value + "'";
141 config.Execute_CUD(sql, "error to delete", "Data has been deleted.");
142 btnnew_Click(sender, e);
143 }
File name: frmItems.cs
Copy
156 private void dtglist_Click(object sender, EventArgs e)
157 {
158 sql = "SELECT * FROM tblitems WHERE ITEMID='" + dtglist.CurrentRow.Cells[0].Value.ToString() + "'";
159 config.singleResult(sql);
160 if (config.dt.Rows.Count > 0)
161 {
162 txtitemid.Text = config.dt.Rows[0].Field
163 txtname.Text = config.dt.Rows[0].Field
164 txtdescription.Text = config.dt.Rows[0].Field
165 txtprice.Text = config.dt.Rows[0].Field
166 cbotype.Text = config.dt.Rows[0].Field
167 //txtqty.Text = config.dt.Rows[0].Field
168 //cbounit.Text = config.dt.Rows[0].Field
169 }
170 }
File name: frmReturn.cs
Copy
31 private void btnreturnadd_Click(object sender, EventArgs e)
32 {
33
34 if (dtCus_addedlist.RowCount == 0)
35 {
36
37 string[] row = new string[] { dtgCus_itemlist.CurrentRow.Cells[0].Value.ToString(),
38 dtgCus_itemlist.CurrentRow.Cells[1].Value.ToString(),
39 dtgCus_itemlist.CurrentRow.Cells[2].Value.ToString(),
40 dtgCus_itemlist.CurrentRow.Cells[3].Value.ToString(),
41 dtgCus_itemlist.CurrentRow.Cells[5].Value.ToString(),
42 dtgCus_itemlist.CurrentRow.Cells[6].Value.ToString(),
43 dtgCus_itemlist.CurrentRow.Cells[7].Value.ToString()};
44
45 dtCus_addedlist.Rows.Add(row);
46
47
48 }
49 else
50 {
51 foreach (DataGridViewRow r in dtCus_addedlist.Rows)
52 {
53 if (dtgCus_itemlist.CurrentRow.Cells[0].Value == r.Cells[0].Value)
54 {
55 MessageBox.Show("Item is already in the cart", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
56 return;
57 }
58 }
59
60 if (dtCus_addedlist.CurrentRow.Cells[0].Value != dtgCus_itemlist.CurrentRow.Cells[0].Value)
61 {
62
63 string[] row = new string[] { dtgCus_itemlist.CurrentRow.Cells[0].Value.ToString(),
64 dtgCus_itemlist.CurrentRow.Cells[1].Value.ToString(),
65 dtgCus_itemlist.CurrentRow.Cells[2].Value.ToString(),
66 dtgCus_itemlist.CurrentRow.Cells[3].Value.ToString(),
67 dtgCus_itemlist.CurrentRow.Cells[5].Value.ToString(),
68 dtgCus_itemlist.CurrentRow.Cells[6].Value.ToString(),
69 dtgCus_itemlist.CurrentRow.Cells[7].Value.ToString()};
70 dtCus_addedlist.Rows.Add(row);
71 }
72 else
73 {
74 MessageBox.Show("Item is already in the cart", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
75 return;
76 }
77
78
79
80 }
81 }
File name: frmReturn.cs
Copy
169 private void btnreturn_remove_Click(object sender, EventArgs e)
170 {
171 dtCus_addedlist.Rows.Remove(dtCus_addedlist.CurrentRow);
172 }
File name: frmSettings.cs
Copy
45 private void btncdel_Click(object sender, EventArgs e)
46 {
47 sql = "DELETE FROM `tblautonumber` WHERE `ID`='" + dtgtypelist.CurrentRow.Cells[0].Value + "'";
48 config.Execute_Query(sql);
49
50 sql = "DELETE FROM `tblsettings` WHERE `ID`='" + dtgtypelist.CurrentRow.Cells[0].Value + "'";
51 config.Execute_CUD(sql, "error to delete data", "Data has been deleted in the database.");
52
53 btntypeLoad_Click(sender, e);
54 }
File name: frmSettings.cs
Copy
56 private void dtgtypelist_Click(object sender, EventArgs e)
57 {
58 txtCategory.Text = dtgtypelist.CurrentRow.Cells[1].Value.ToString();
59 typeid = dtgtypelist.CurrentRow.Cells[0].Value.ToString();
60 }
File name: frmSettings.cs
Copy
77 private void btnunit_Click(object sender, EventArgs e)
78 {
79 sql = "DELETE FROM `tblsettings` WHERE `ID`='" + dtgulist.CurrentRow.Cells[0].Value + "'";
80 config.Execute_CUD(sql, "error to delete date", "Data has been deleted in the database.");
81 btntypeupdate_Click(sender, e);
82 }
CurrentRow 285 lượt xem
Gõ tìm kiếm nhanh...