borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (new database)Next Topic (Update Primary Key at run time) New Topic New Poll Post Reply
AndreaVB Forum : Database : MSHFLEXGRID
Poster Message
elgy
Level: Scholar

Registered: 20-07-2005
Posts: 42

icon MSHFLEXGRID

How can I make mshflexgrid coloured, for ex:
on odd rows white, and on even rows is yellow.?

how to make width of the fixed rows automatically adjust the text in it??

can anybody post the full properties of mshflexgrid?? thxx

16-05-2007 at 03:15 AM
View Profile Send Email to User Show All Posts | Quote Reply
Mike Sabatier
Level: Protégé

Registered: 05-03-2007
Posts: 6
icon Re: MSHFLEXGRID

Hi elgy

A little routine which scans down the grid (hfgGrid) testing if the row number is ODD (the row number MOD 2 <> 0) sets the row colour (CellBackColor) to vbWhite or is EVEN (the row number MOD 2 = 0) sets the row colour(CellBackColor) to vbYellow would do the trick for selected cells.
If you put the code into a routine with parameters, you could call the routine for different grids with different colours or allow the user to select the different colours from, say, a combobox .

Public Sub GridSetAltRowColours(phfgGrid As MSHFlexGrid, plngColour1 As Long, plngColour2 As Long)
'Sets colours of alternate grid rows to specified colours****

  'Declare local variables and allocate storage space *******
  Dim pintRow As Integer
  'Scan grid rows setting colours ************************
  With phfgGrid
    If .Rows > 1 Then  'Assuming a FIXED header row of labels
      .Col = 0              'Select from first column
      For pintRow = 1 To .Rows - 1
          .Row = pintRow
          .ColSel = .Cols - 1           'Select to last column
          .FillStyle = flexFillRepeat   'Applies to all selected cells
          If pintRow Mod 2 <> 0 Then         'RowNum is Odd
              .CellBackColor = plngColour1   'Set first colour
          Else
              .CellBackColor = plngColour2   'RowNum is Even
           End If
      Next pintRow
    End If
  End With
End Sub

The routine could then be called as follows:
          'Set alternate row colours in Transactions grid ******
          Call GridSetAltRowColours(hfgTrans, vbWhite, vbYellow)

or, say:
          'Set alternate row colours in Receipts grid **********
          Call GridSetAltRowColours(hfgReceiptss, vbCyan, vbWhite)

This was fun - I hope you like it

16-06-2007 at 11:17 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : MSHFLEXGRID
Previous Topic (new database)Next Topic (Update Primary Key at run time) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder