R
Roger Lainson
Hi,
Can anyone suggest how to select or hilight a column in a Windows
Forms datagrid, as visual feedback for an edit/copy command?
I've tried ...
private void mydatagrid_Mousedown(object sender, MouseEventArgs e)
{
// Determine location of mouse click.
DataGrid.HitTestInfo hit = mydatagrid.HitTest(e.X, e.Y);
if (hit.Type == DataGrid.HitTestType.ColumnHeader)
{
DataGridTextBoxColumn col = (DataGridTextBoxColumn)
mydatagrid.TableStyles[0].GridColumnStyles[hit.Column];
DataGridTextBox dt = (DataGridTextBox) col.TextBox;
dt.BackColor = System.Drawing.Color.Red; // just for test
}
}
.... from a snippet somewhere in the MSDN library, but this causes
cells in the hit column to have a red background only if and while
they become selected; otherwise they appear normal. Any suggestions,
or another approach altogether?
Roger.
Can anyone suggest how to select or hilight a column in a Windows
Forms datagrid, as visual feedback for an edit/copy command?
I've tried ...
private void mydatagrid_Mousedown(object sender, MouseEventArgs e)
{
// Determine location of mouse click.
DataGrid.HitTestInfo hit = mydatagrid.HitTest(e.X, e.Y);
if (hit.Type == DataGrid.HitTestType.ColumnHeader)
{
DataGridTextBoxColumn col = (DataGridTextBoxColumn)
mydatagrid.TableStyles[0].GridColumnStyles[hit.Column];
DataGridTextBox dt = (DataGridTextBox) col.TextBox;
dt.BackColor = System.Drawing.Color.Red; // just for test
}
}
.... from a snippet somewhere in the MSDN library, but this causes
cells in the hit column to have a red background only if and while
they become selected; otherwise they appear normal. Any suggestions,
or another approach altogether?
Roger.