View Full Version : C#.NET Datagrid Manipulation

12-15-2004, 01:20 AM

I'm trying to do something fairly complex in .NET with a datagrid component. I'm trying to select a whole row at a time and then when the user right clicks they get a context menu appearing which gives them some actions they can do per row. Such as edit, delete or view item.

The datagrid gets its data from a database, when the user clicks edit on a datagrid item i want it to launch a another form where they can edit etc...

Each row contains all of the columns from the db, so when i click edit or delete in the menu i need to grab the ID from the id column so i can query the database again.

So far i have coded it so i can select an entire row, but i need to know how to pull the data from the ID column, I think I am half way there but i've just got stuck now.

Any help would be much appriecated :)

Heres my row selection code

System.Drawing.Point point = new Point(e.X, e.Y);
DataGrid.HitTestInfo hit= dataGrid1.HitTest(point);

if(hit.Type == DataGrid.HitTestType.Cell)
dataGrid1.CurrentCell = new DataGridCell(hit.Row, hit.Column);