Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Select a COLUMN in a datagrid?

Reply
Thread Tools

Select a COLUMN in a datagrid?

 
 
Roger Lainson
Guest
Posts: n/a
 
      02-09-2004
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.
 
Reply With Quote
 
 
 
 
Rob Windsor [MVP]
Guest
Posts: n/a
 
      02-09-2004
Check out:
http://www.syncfusion.com/faq/winforms/search/893.asp

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


"Roger Lainson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView - Setting the text of the 'select' column to the value of another column Greg Smith ASP .Net 0 04-12-2007 03:11 PM
GridView - Setting the text of the 'select' column to the value of another column Greg Smith ASP .Net Web Controls 0 04-12-2007 02:40 PM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM
How to bind a db image column (byte array) to a datagrid column? Jim Hammond ASP .Net 1 11-26-2003 12:55 AM
Templated column cannot access datasource column ASP .Net 2 11-10-2003 03:58 PM



Advertisments