Get cell text from a winform datagrid.

M

Marre

Hi all!

I have made a datagrid on a winform and want to get the text out of the
first cell when I have the row selected. Lets say I have a grid with som
info and want to view more info about the selected row, how do I do that?

Regards
Marre
 
M

Marre

Well, I found it on msdn. It looks like this:

DataGridCell currentCell;

string currentCellData;

// Get the current cell.

currentCell = dgApplication.CurrentCell;

// Get the current cell's data.

currentCellData =
dgApplication[currentCell.RowNumber,currentCell.ColumnNumber].ToString();

// Set the TextBox's text to that of the current cell.

MessageBox.Show(currentCellData);

Regards
Marre
 

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

Top