![]() |
Tipp 0264
|
Zellfarbe zeilen-/spaltenweise festlegen
|
 |
|
Autor/Einsender: Datum: |
|
Manuel Schneider 17.08.2002 |
|
Entwicklungsumgebung: |
|
VB 6 |
|
|
Mit diesem Tipp lässt sich die Hintergrundfarbe der Zellen eines MSHFlexGrid-Steuerelements
je nach Auswahl der Farbkombination abwechselnd entweder Zeilen- oder
Spaltenweise festlegen.
|
|
|
Option Explicit
Private Sub Form_Load()
With Combo1
.AddItem "rosa / weiß"
.AddItem "gelb / weiß"
.AddItem "rosa / grau"
.ListIndex = 0
End With
End Sub
Private Sub Combo1_Click()
Dim lColor1 As Long
Dim lColor2 As Long
Dim lStyle As Long
Select Case Combo1.ListIndex
Case 0
lColor1 = &HC0C0FF
lColor2 = &HFFFFFF
Case 1
lColor1 = &HC0FFFF
lColor2 = &HFFFFFF
Case 2
lColor1 = &HC0C0FF
lColor2 = &HE0E0E0
End Select
If Me.Option1(0) Then lStyle = 0 Else: lStyle = 1
SetGridCellBackColor MSHFlexGrid1, lColor1, lColor2, lStyle
End Sub
Private Sub Option1_Click(Index As Integer)
Combo1_Click
End Sub
Private Sub SetGridCellBackColor(ByVal fGrid As MSHFlexGrid, _
ByVal lngColor1 As Long, ByVal lngColor2 As Long, _
ByVal lngStyle As Long)
Dim lngFirstRow As Long
Dim lngFirstCol As Long
Dim r As Long
Dim c As Long
With fGrid
.Redraw = False
lngFirstRow = .FixedRows
lngFirstCol = .FixedCols
If lngStyle = 0 Then
For r = lngFirstRow To .Rows - 1
For c = lngFirstCol To .Cols - 1
.Row = r: .Col = c
If (r + lngFirstRow) Mod 2 = 0 Then
.CellBackColor = lngColor1
Else
.CellBackColor = lngColor2
End If
Next c
Next r
Else
For c = lngFirstCol To .Cols - 1
For r = lngFirstRow To .Rows - 1
.Row = r: .Col = c
If (c + lngFirstCol) Mod 2 = 0 Then
.CellBackColor = lngColor1
Else
.CellBackColor = lngColor2
End If
Next r
Next c
End If
.Redraw = True
End With
End Sub
|
|
|
|
|
|
Um diesen Tipp ausführen zu können, muss das Microsoft
Hierarchical FlexGrid Control als Komponente in das Projekt eingebunden
werden.
|
|
Windows-Version |
95 |
 |
|
98/SE |
 |
|
ME |
 |
|
NT |
 |
|
2000 |
 |
|
XP |
 |
|
Vista |
 |
|
Win
7 |
 |
|
|
VB-Version |
VBA 5 |
 |
|
VBA 6 |
 |
|
VB 4/16 |
 |
|
VB 4/32 |
 |
|
VB 5 |
 |
|
VB 6 |
 |
|
|
|
Download (3,4
kB)
|
Downloads bisher: [ 1154 ]
|
|
|