Solved

colored cells in data grid - vb6

Posted on 2013-06-21
2
665 Views
Last Modified: 2013-06-21
In vb6 I am trying to color the 2nd row in my datagrid and put the width at 1500.  I have figured out how to do the width but I can't figure out how to change the color of only the second column.  Is this possible?  I am trying to make the column stand out somehow.


DataGrid1.Columns(24).Width = 1500

Open in new window

0
Comment
Question by:al4629740
  • 2
2 Comments
 
LVL 46

Accepted Solution

by:
Martin Liss earned 500 total points
ID: 39266139
I don't believe you can do it with a datagrid, but you can with a flexgrid and here's an example I found on the web.


Private Sub Form_Load()
MSFlexGrid1.FixedRows = 0
FlexGridColumnColor MSFlexGrid1, 1, vbRed
End Sub

Public Sub FlexGridColumnColor(FlexGrid As MSFlexGrid, ByVal lngColumn As Long, ByVal lngColor As Long)
    Dim lngPrevCol As Long
    Dim lngPrevColSel As Long
    Dim lngPrevRow As Long
    Dim lngPrevRowSel As Long
    Dim lngPrevFillStyle As Long
    If lngColumn > FlexGrid.Cols - 1 Then
        Exit Sub
    End If
    lngPrevCol = FlexGrid.Col
    lngPrevRow = FlexGrid.Row
    lngPrevColSel = FlexGrid.ColSel
    lngPrevRowSel = FlexGrid.RowSel
    lngPrevFillStyle = FlexGrid.FillStyle
    FlexGrid.Col = lngColumn
    FlexGrid.Row = FlexGrid.FixedRows
    FlexGrid.ColSel = lngColumn
    FlexGrid.RowSel = FlexGrid.Rows - 1
    FlexGrid.FillStyle = flexFillRepeat
    FlexGrid.CellBackColor = lngColor
    FlexGrid.Col = lngPrevCol
    FlexGrid.Row = lngPrevRow
    FlexGrid.ColSel = lngPrevColSel
    FlexGrid.RowSel = lngPrevRowSel
    FlexGrid.FillStyle = lngPrevFillStyle
End Sub

Open in new window

0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39267523
You're welcome and I'm glad I was able to help.

Select the 'About Me' tab in my profile and you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2013
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Vb.net 2008 2 56
change vba from autofit to 13.5 width? 4 28
Visual Studio 2005 text editor 10 35
How to set the row selection as it was prior leaving the datagrid in vb6 3 34
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now