Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

colored cells in data grid - vb6

Posted on 2013-06-21
2
Medium Priority
?
714 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 49

Accepted Solution

by:
Martin Liss earned 2000 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 49

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

886 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