Is there a bug w/ the DataGridView?
Hi all,
I'm using the following code:
ForEach SelectedRowAs DataGridViewRowIn grd.SelectedRowsSelectedRow.Cells(
"IsTrue").Value =TrueNextEx. of my problem:
Row|IsTrue
1 |0
2 |0
Using the above code will only make Row 1 True, and leave Row 2 as False. If I just Select Row 1, then the code above sets Row 1 to True just fine.
The ONLY way to make it work is to hard-code the following:
grd.Item(
"IsTrue", 0).Value =Truegrd.Item(
"IsTrue", 1).Value =Truegrd.Item(
"IsTrue", 2).Value =TrueAny variable in the row index of grd.Item produces the same problem. It MUST be hard-coded.
Anyone know why?
- Thanks ahead of time.
[2004 byte] By [
Denvas] at [2007-12-26]
Public
Class Form2Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickFor Each SelectedRow As DataGridViewRow In Me.DataGridView1.SelectedRowsSelectedRow.Cells(
"Column2").Value = TrueNextEnd SubEnd
Class
just tried your code with a checkbox column as column2, and it works properly,
selected row is a row selected by clicking on row header, so to select multiple rows, i had to hold control and click on the multiple row headers(on the left). and it worked. , what are you setting to true actually?
Hi,
Thanks for the response. The column I'm setting to true is a check box column. And what's weird is that it won't check off the last box, until you select another row (after the code has run) - then it just checks itself automatically. So the value is set to True (F8'ing it), but it doesn't reflect on the form till the second step of clicking on another row.