can't get selected row to register

  • Thread starter Thread starter Patrick Sullivan
  • Start date Start date
P

Patrick Sullivan

selectedItem = datagrid1.Item(selectedCell.RowNumber,
selectedCell.ColumnNumber)

lblTest.Text = selectedItem.ToString

answers come out to be row 0 column 1 everytime, the first row in the table,
no matter which row I select.
TIA
 
Hi,

Patrick Sullivan said:
selectedItem = datagrid1.Item(selectedCell.RowNumber,
selectedCell.ColumnNumber)

lblTest.Text = selectedItem.ToString

- I'm not using this but afaik it should work:

Dim dgc As DataGridCell = datagrid1.CurrentCell
lblTest.Text = datagrid1.Item( dgc.RowNr, dgc.ColumnNr ).ToString()


- You can also get the current DataRowView from the CurrencyManager and then
get the value for an individual cell:

Dim drv As DataRowView = DirectCast(
datagrid1.BindingContext(datagrid1.DataSource,
datagrid1.DataMember).Current, DataRowView)

lblTest.Text = drv( colIdx -or- colName ).ToString()


HTH,
Greetings
 
Bart Mermuys said:
Hi,



- I'm not using this but afaik it should work:

Dim dgc As DataGridCell = datagrid1.CurrentCell
lblTest.Text = datagrid1.Item( dgc.RowNr, dgc.ColumnNr ).ToString()


- You can also get the current DataRowView from the CurrencyManager and then
get the value for an individual cell:

Dim drv As DataRowView = DirectCast(
datagrid1.BindingContext(datagrid1.DataSource,
datagrid1.DataMember).Current, DataRowView)

lblTest.Text = drv( colIdx -or- colName ).ToString()


HTH,
Greetings

Thanks Bart, I stayed up half the night trying to get it to do what I want
and finally got it, now you show a simpler looking solution. LOL, I will
have to try that out too. see my next post for what I did.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top