Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Datagrid Control (http://www.velocityreviews.com/forums/f60-asp-net-datagrid-control.html)
-   -   Select a COLUMN in a datagrid? (http://www.velocityreviews.com/forums/t760243-select-a-column-in-a-datagrid.html)

Roger Lainson 02-09-2004 10:30 PM

Select a COLUMN in a datagrid?
 
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.

Rob Windsor [MVP] 02-09-2004 11:20 PM

Re: Select a COLUMN in a datagrid?
 
Check out:
http://www.syncfusion.com/faq/winforms/search/893.asp

--
Rob Windsor [MVP-VB]
G6 Consulting
Toronto, Canada


"Roger Lainson" <roger@sdr.com.au> wrote in message
news:23e9edf7.0402091430.1a2adfb6@posting.google.c om...
> 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.





All times are GMT. The time now is 08:44 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.