Results 1 to 3 of 3

Thread: Changing background color of datagrid row in windows forms

  1. #1
    sups123 is offline VB.NET Forum Newbie
    .NET Framework
    .NET 1.1 (VS 2003)
    Join Date
    Mar 2006
    Posts
    14
    Reputation
    105

    Changing background color of datagrid row in windows forms

    Hello,

    We have a datagrid in windows form. We want to change the background color of row according to some condition.

    Got many examples in ASP.net but there are no examples of windows forms.

    Please your reply will be highly appreciated.

    Regards,
    sups

  2. #2
    JohnH's Avatar
    JohnH is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Dec 2005
    Location
    Norway
    Posts
    14,471
    Reputation
    2732
    Moved to suitable forum Winform Grids.

    You have to use Table Styles and Column Styles. See this article "Formatting the Windows Forms DataGrid Control"
    http://msdn.microsoft.com/library/de...DesignTime.asp

    Note that Datagrid is a column based control.

  3. #3
    ImDaFrEaK is offline VB.NET Forum Miyagee
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Jan 2006
    Location
    California
    Posts
    416
    Reputation
    115

    Smile

    Here are some ways to change colors to the GridView Component.

    Code:
    
    Me.DataGridView1.RowsDefaultCellStyle.BackColor = Color
    Me.DataGridView1.BackgroundColor = Color
    Me.DataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color
    Me.DateGrivView1.ForeColor = Color
    There are many other ways and colors you can alter on the DataGridView. It's a freaking confusing component and there should be a class dedicated just to that tool I think, lol. Anyways, I figured out that much using it myself.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking