retrieve value from a field in Datagrid!

Duckjibe

Member
Joined
Sep 10, 2002
Messages
15
Hello i got a problem to get the value from a cell in the Datagrid!

I got an searchoption to fill my datagrid..... now the user has to select item he wants to se more about.

The value is always stored in Column0 but the rows are always different.

I know how to get the value from a specified Cell

like

Value = DataGrid1.Item(0, 0)

but it isnt always 0, 0 it could also be 1, 0 or something!!

so what can i do

I also found something here

You can do this for column number....
MessageBox.Show(myGrid1.CurrentCell.ColumnNumber.ToString)

Row number...
MessageBox.Show(myGrid1.CurrentCell.RowNumber.ToString)

Both row and column (as string)
MessageBox.Show(myGrid1.CurrentCell.ToString)
But the string i get doesnt contain the value of the field just where i selected!!!!!

I love to hate programming:D

Thanks for any advice!

Bye
 
just use
value = datagrid1.item(datagrid1.currentcell)

This will return the value of the current cell.
Thw mygrid1.currentcell returns the number of the row and column of the current cell, therefore if you want the value of the first column of the selected row the sintax is the following:

value = mygrid1.item(mygrid1.currentcell, 0)
 
Back
Top