Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Winforms Datagrid

Status
Not open for further replies.

Eli20

Programmer
Oct 30, 2003
119
0
0
MX
hi, i have a datagrid in my application, bound to a datatable from a dataset.

i need that when the user changes a value in a cell (in certain column) another column changes (i make some calculations)

but im having trouble finding out first, how to get the text that the user just types, and second, how to change the text of the other column.

can anybody help me?

im working on the CurrentCellChanged event´

thank you very much
Eli
 
You can find the selected row of the datagrid with dgMyGrid.CurrentRowIndex, which returns an int, or the selected cell with dgMyGrid.CurrentCell, which returns a DataGridCell.

You can reference the contents of a cell with either dgMyGrid[int row, int column] or dgMyGrid[DataGridCell].

A DataGridCell has ColumnNumber and RowNumber properties, both ints.

That should get you going.

Regards

Nelviticus
 
but how do i get the text of that cell?

and how do i write on it?

thank you

Eli
 
To get the text:

Code:
string sMyText = dgMyGrid[iRow, iColumn].ToString();

To set it (after checking that its type is string):

Code:
dgMyGrid[iRow, iColumn] = "Some value";

Regards

Nelviticus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top