Thursday, June 07, 2012 12:58 PM
hi i have a prblobem
i wrote this code in
foreach (DataGridViewRow R1 in dataGridView1.Rows)
foreach (DataRow Row in T.Rows)
if (Convert.ToInt32(R1.Cells.Value) == Convert.ToInt32(Row))
R1.Cells.Value = Convert.ToInt64(Row);
but no data apper in the datagridview
when i wrote it in button click
the data appers
how can i solve it in the form load??
- Moved by CoolDadTxMVP Thursday, June 07, 2012 1:52 PM Winforms related (From:Visual C# General)
Thursday, June 07, 2012 1:21 PMDo you set the DataSource and execute DataBind for the DataGridView before executing the query above?
Thursday, June 07, 2012 1:23 PMyes i do it
Thursday, June 07, 2012 1:43 PM
Try to use DataGridView.DataBindingComplete event.
Check this link for instructions: http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.databindingcomplete.aspx
Thursday, June 07, 2012 4:55 PMYep, DataBindingComplete event would do the trick for you. If you handle that event (and put a breakpoint), you'll see that it's fired a few times (about 2 or 3 times) when you bind your DataGridView for the first time, and the first time around you'll see that there are no rows in the DataGridView. Subsiquent bindings only fire once. As to the explanation of this behavior, well, ... :-)
"'Impossible' doesn't mean something cannot be done. It simply means no solution is known to the individual(s) in question." - Mbongo M. Mpongwana
Friday, June 08, 2012 5:48 AM
Is there any data or rows in your DGV before you run this loop to update cell value.
Else, put a break point and check how many rows you have in DGV and debug each step to find the cause.
And if it still doesn't work, post your code!
Amit Govil | Email
"Weeks of coding can save you hours of planning"
Wednesday, June 13, 2012 5:57 AMModerator
Any update to this issue?
There many reason can cause this issue. For example, the row count in the DataGridView is zero.
It is hard to detect the issue without the code. I suggest you debug the code line by line.
If the issue is still not solved, could you please post your code here?
Bob Wu [MSFT]
MSDN Community Support | Feedback to us