Cell Events in Windows Datagrid

G

Guest

I have a datagrid that sits on a panel control. It has a Dataview bound to
it as its datasource that allows me to have the data sorted when it first
displays. I also AllowSorting on the grid.

I need to be able to determine when a specfic cell has been clicked and see
the value of that cell. This is all done with code vs using the IDE. If it
matters I have created a DataGridTableStyle to be able to set the column
width etc., and that seems to be working just fine.

The only events I've been able to get to fire so far are the Click and
DoubleClick for the row. I see the CurrentCell property, and the
CurrentCellChanged event in the doc, but have not been able to see the
property or get the event to fire. I know something is happening because at
run time when I click on a cell the contents are highlighted. I just need to
be able to get some additional code in that event.

In addition, I have progammtically added a line to set the
AlternatingBackColor property, but the grid seems to ignore that. Other
properties I set (i.e. Datasource) do seem to work.

Thanks for any help.

WhiteWizard (aka Gandalf)
 
B

Brett Romero

Are you trying to get a single cell value from a user click? If so,
have you tried HitTest?

Point pt = new Point(e.X, e.Y);
System.Windows.Forms.DataGrid.HitTestInfo hit = this.HitTest(pt);

Brett
 

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