Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 ?

Posted

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

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

Posted
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# ?

Posted
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.

Anybody looking for a graduate programmer (Midlands, England)?
Posted
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.

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...