Jelmer Posted February 27, 2006 Posted February 27, 2006 How can i get the rownumber from a Datagridview. In some other programming languages you can use e selectedindex ore something. What i need: I select a row, and i like to get something out of it.. dataGridView1.Rows[1].Cells[0].Value.ToString() Row = 1 at that code.. That 1 should be the rownumber of the selected row... How ? Quote
SonicBoomAu Posted February 27, 2006 Posted February 27, 2006 If I need to get the first column value from a datagrid I use the following DataGrid1(DataGrid1.CurrentRowIndex, 0).ToString() So in your case if would most probably look like this: dataGridView1(dataGridView1.currentRowindex, 0).ToString() Hope this helps :D Quote Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. -- Rick Cook, The Wizardry Compiled
Jelmer Posted February 28, 2006 Author Posted February 28, 2006 If I need to get the first column value from a datagrid I use the following DataGrid1(DataGrid1.CurrentRowIndex, 0).ToString() So in your case if would most probably look like this: dataGridView1(dataGridView1.currentRowindex, 0).ToString() Hope this helps :D Sorry i forgot to say that i use C# dataGridView1.currentRowindex doesnt exist in C# ? Quote
Jelmer Posted February 28, 2006 Author Posted February 28, 2006 In C# ist like this.. i found it just out :) dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value.ToString() Quote
Cags Posted February 28, 2006 Posted February 28, 2006 Sorry i forgot to say that i use C# dataGridView1.currentRowindex doesnt exist in C# ? CurrentRowIndex is a property of a DataGrid, however you are using a DataGridView which presumably has different properties. I can't help however as I don't appear to have this control, assumably its a VS 2005 control. Quote Anybody looking for a graduate programmer (Midlands, England)?
Joe Mamma Posted February 28, 2006 Posted February 28, 2006 CurrentRowIndex is a property of a DataGrid' date=' however you are using a DataGridView which presumably has different properties. I can't help however as I don't appear to have this control, assumably its a VS 2005 control.[/quote']you shouldnt be getting your data out of the grid, you should be getting it out of the bound data. use a binding source. BindingSource.Current is the underlying object displayed in the selected row of the grid. Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
rmokkenstorm Posted March 1, 2006 Posted March 1, 2006 and how can i read out this string or someting in a other form ? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.