datagrid events

  • Thread starter Thread starter Robert Smith
  • Start date Start date
R

Robert Smith

Hello,
I have a datagrid called dgprojects that is bound to
a dataset called dsprojects. However I wish to detect when
the user scrolls down the grid and selects another row, so
that I can call another procedure using the element in the
first column of the row as the parameter.

Thanx in advance
Robert
 
Setup an event handler for the datagrid's CurrentCellChanged event and
it will notify you when the cell changes. It won't, however, notify you
if you are merely scrolling without selecting another cell. Does this
answer your question?

You can then get the current row number and data values like this:
int rowNum = messagesDataGrid.CurrentCell.RowNumber;
object unitname = messagesDataGrid[rowNum, 0]; // column 0
object fldtimestamp = messagesDataGrid[rowNum, 1];
object payload = messagesDataGrid[rowNum, 2];
object state = messagesDataGrid[rowNum, 4]; // column 4
readTextBox.Text = payload.ToString();

Steve
 

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