DataGridView Cell MouseOver

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How to access the full text of a cell when i mouseover on a DataGridView
Cell. I need to get it like a tool tip when i mouseover on a DataGridView
Cell. Any Sample code is greately appreciated.

Thank you
 
Hi,

you have to write code like this:

public class MyDataGrid: DataGrid {
....
protected override void OnMouseMove(MouseEventArgs e) {
base.OnMouseMove (e);

DataGrid.HitTestInfo hti = HitTest(new Point(e.X, e.Y));

if (hti.Type == DataGrid.HitTestType.Cell) {
DataGridCell cell = new DataGridCell(hti.Row, hti.Column);

// lastValue gives you the value of the cell content
object lastValue = this[cell.RowNumber,
cell.ColumnNumber];

....
// or you use this code to get the current list item: e.g. an object
with
// public bindable properties or a DataRowView
object item = ListManager.List[cell.RowNumber];
....
}

Regards, Walter
 
Hi Walter,

Thank you for the code. I need to display the text as a tool tip when i
mouse hover on the DataGrid Column. appreciate if you can help me.

Thank you.

Walter Leinert said:
Hi,

you have to write code like this:

public class MyDataGrid: DataGrid {
...
protected override void OnMouseMove(MouseEventArgs e) {
base.OnMouseMove (e);

DataGrid.HitTestInfo hti = HitTest(new Point(e.X, e.Y));

if (hti.Type == DataGrid.HitTestType.Cell) {
DataGridCell cell = new DataGridCell(hti.Row, hti.Column);

// lastValue gives you the value of the cell content
object lastValue = this[cell.RowNumber,
cell.ColumnNumber];

...
// or you use this code to get the current list item: e.g. an object
with
// public bindable properties or a DataRowView
object item = ListManager.List[cell.RowNumber];
...
}

Regards, Walter

Bidarkota said:
How to access the full text of a cell when i mouseover on a DataGridView
Cell. I need to get it like a tool tip when i mouseover on a DataGridView
Cell. Any Sample code is greately appreciated.

Thank you
 
Back
Top