Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Iterate through datgridview in winforms
 

Iterate through datgridview in winforms

Hi all

foreach (DataRow dtrow in newdt.Rows)
{
int fundid = Convert.ToInt32(dtrow["fundId"].ToString());
foreach(DataGridViewRow row in dgvallocation.Rows)
{

DataGridViewComboBoxCell obj = new DataGridViewComboBoxCell();
row.Cells[4] = obj;
DataView dv = new DataView(DTBankAccounts, "fundId = " + fundid, "", DataViewRowState.CurrentRows);

obj.DisplayMember = "accountID";
obj.ValueMember = "accountID";
obj.DataSource = dv;

}
}

I have a datatable newdt and datagridview dgvallocation
I am trying to iterate through the datatable and get the fundid and iterate through the datagridview where i have comboxcolumn ,based upon the fundid i am setting the datasource for comboboxcell in each row

when i try the above code i am not able to move to second row of the datagridview

How to achieve this

Regards
DAM
damu maddy  Friday, January 16, 2009 1:55 PM
Bruce

I solved my issue How to close this thread


Regards
damodar
damu maddy  Thursday, January 22, 2009 9:08 PM
Hi damu maddy,

I am not quite sure with your problem. What does "I am not able to move to the second row of the DataGridView" mean? Where does the code snippet locate in your program. In the constructor, load event handler or other places? The most important thing, I don't think the code you are writing can achive your goal, you can see if there are there rows in the datatable, the DataSource of all the rows in the DataGridView will be set three times, the result can't be predicted.

So would you please clarify what you want to achieve in your real scenario? I will try my best to help you find a solution.

Best regards,
Bruce Zhou

Please mark the replies as answers if they help and unmark if they don't.
Bruce.Zhou  Monday, January 19, 2009 4:43 AM
We are changing the issue type to “General Discussion�because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question�by opening the Options list at the top of the post editor window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.

Thanks.



Please mark the replies as answers if they help and unmark if they don't.
Bruce.Zhou  Thursday, January 22, 2009 9:42 AM
Bruce

I solved my issue How to close this thread


Regards
damodar
damu maddy  Thursday, January 22, 2009 9:08 PM
Hi damu maddy,

We can not see the "Mark" icon if the type of this thread is "General Dicussion". Not I've changed the type to "Question" again and close this thread by marking your last post.

Best regards,
Bruce Zhou


Please mark the replies as answers if they help and unmark if they don't.
Bruce.Zhou  Friday, January 23, 2009 2:45 AM

You can use google to search for other answers

Custom Search

More Threads

• Problem deleting containers in designer
• How can I access the DTE (solution components) at design time?
• Help!! Please Help (Timers problem)
• Help with creating a custom designer
• removing inherited properties
• PropertyGrid.OnComponentRemoved throws ArgumentException
• Removing (Disabling) the veritical scrollbar in a listbox
• Don't want design mode
• How do I get the true underlying GroupBox text color property from Color.ControlText
• Custom ExpandableObjectConverter to show the contents of the selected Control