Solved

colored cells in data grid - vb6

Posted on 2013-06-21
2
656 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 45

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 45

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 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…

758 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

21 Experts available now in Live!

Get 1:1 Help Now