Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

colored cells in data grid - vb6

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 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