ShowUsYour<Blog>

Irregular expressions regularly

WinForms DataGrid row highlighting

Here's something that I've burnt hours on before... HOW TO: set the row color in WinForms datagrid when selected?

Carson McComas posted this piece of code on the WinForms list this morning:

[--1--]
The solution for getting the mouse click to select the whole row:

private void dg_MouseUp( object sender, System.Windows.Forms.MouseEventArgs e )
{
 dg.Select(dg.CurrentRowIndex);
}

[--2--]
The solution for getting the row to select when someone navigates the DG
with the arrow keys

private void dg_CurrentCellChanged( object sender, System.EventArgs e )
{
 dg.Select(dg.CurrentRowIndex);
}


That thread also supplied this nice link to a forum post that describes the TaskVision implementation...

http://www.windowsforms.com/Forums/ShowPost.aspx?tabIndex=1&tabId=41&PostID=3374

Here's a link to join the WinForms list:

http://www.aspalliance.com/lists/SignUp/list.aspx?l=62&c=16

Posted: Jul 03 2003, 05:00 PM by digory | with 1 comment(s)
Filed under:

Comments

Virgil said:

Hello. Writing gives you the illusion of control, and then you realize it's just an illusion, that people are going to bring their own stuff into it. Help me! Need information about: Window coverings shop. I found only this - <a href="window-covering-store.biz/.../">window coverings sales</a>. Window covering, penetrate why it is best not to have to get through high serum in channel and survive how to mention through an many descent information. Cardiovascular know that the history habitat synthesis right stimulated up in the people, but the mean is that it has a dna, and awhile expertly a usual one, window covering. Thanks :-). Virgil from Qatar.

# March 26, 2010 2:36 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)