none
DataGridView Link Column Highlight ForeColor RRS feed

  • Question

  • I have a datagridview and I have set the highlight property to full row, I also have a link column in my grid.

    my problem is, when I click on a row it get highlighted blue, but the link color is also blue so it becomes very hard to read.

    is there a way other than manually setting the cell forecolor to handle this issue?
    Tuesday, May 26, 2009 11:31 AM

Answers

  • I think link color does not work if its changed after binding the data, check the name of the link Column and try code this way 

    To check the name or change these color in design time, right click datagridview, edit columns, select the column and check the property, you will find them there

     colLink.LinkColor = Color.Orange  'eg: collink is the name of column
            colLink.VisitedLinkColor = Color.Pink
            colLink.ActiveLinkColor = Color.White

    If you want to change colour using column index then

    Dim mycolumn = CType(DataGridView1.Columns(2), DataGridViewLinkColumn)
            mycolumn.LinkColor = Color.Orange
            mycolumn.VisitedLinkColor = Color.Pink
            mycolumn.ActiveLinkColor = Color.White



    Arjun Paudel
    Tuesday, May 26, 2009 1:11 PM

All replies

  • hi

    try this

     dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
     
    refer this link for more information
    http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcellstyle.backcolor(VS.80).aspx

    http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcellstyle.backcolor(VS.80).aspx


    Hope this helps..
    thx
    anliS
    Regards anliS www.businessinsightsconsulting.com
    Tuesday, May 26, 2009 11:35 AM
  • Hi anliS,
    thanx for the reply but that doesn't work.

    I have tried everything that I can think of so far.

    what doesn't work..

    test 1 - Me.Column1.DefaultCellStyle.SelectionForeColor = Color.White

    test 2 - DataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White

    I have also tried trapping the DataGridView1.RowPostPaint and setting the cell forecolor but that didnt work either.

    More answers greatly welcomed :-)

    Dogs_Bollox
    Tuesday, May 26, 2009 12:23 PM
  • I don't know it helps you but you can give it a try, it is from Ken because I would write colour

    \\\
    To be able to change the backcolor of a DataGridView column header you need to turn off the DataGridView's Visual Styles for the Column Headers

    DataGridView1.EnableHeadersVisualStyles =

    False

    DataGridView1.Columns(0).HeaderCell.Style.BackColor = Color.SkyBlue
    ///

    Tuesday, May 26, 2009 1:09 PM
  • I think link color does not work if its changed after binding the data, check the name of the link Column and try code this way 

    To check the name or change these color in design time, right click datagridview, edit columns, select the column and check the property, you will find them there

     colLink.LinkColor = Color.Orange  'eg: collink is the name of column
            colLink.VisitedLinkColor = Color.Pink
            colLink.ActiveLinkColor = Color.White

    If you want to change colour using column index then

    Dim mycolumn = CType(DataGridView1.Columns(2), DataGridViewLinkColumn)
            mycolumn.LinkColor = Color.Orange
            mycolumn.VisitedLinkColor = Color.Pink
            mycolumn.ActiveLinkColor = Color.White



    Arjun Paudel
    Tuesday, May 26, 2009 1:11 PM
  • Arjun,
    the issue arises when I select a row, the entire row highlights, but even though I have set the linkcolumn highlight color to white, the link shows as blue, making it almost impossible to read against the highlighted row

    Dogs_Bollox
    Wednesday, May 27, 2009 8:57 AM
  • When Did you set those colur? Set them before binding to grid, in design time or in form load.

    Use following property
         mycolumn.LinkColor = Color.Orange
            mycolumn.VisitedLinkColor = Color.Pink
            mycolumn.ActiveLinkColor = Color.White


    Arjun Paudel
    Wednesday, May 27, 2009 9:01 AM
  • Arjun,
    I have tried setting the property at design and runtime, starting with a linkcolumn and also adding one at runtime, it appears that this may just be a datagridview bug.

    many thanks for your help so far...

    Dogs_Bollox
    Thursday, May 28, 2009 12:59 PM