Askerion
2013-03-18T13:41:33Z
Hello,

could you tell me how do I change the header (see attachment) with a button click event.

I would like to change the font color or the background color

I did it myself header hinbekommen the micelles to change color with a button, but unfortunately I can not find the code for the group

with this code can i change the cell color

DataGridViewStatus.Rows(1).Cells(3).BackColor = Color.Red
this works fine


Please help me
Askerion attached the following image(s):
Igor/10Tec
2013-03-18T14:27:33Z
In iGrid, the contents of group rows are stored in so called "row text cells". For a row, you can access it through the RowTextCell property instead of Cells like in your code:

DataGridViewStatus.Rows(1).RowTextCell.BackColor = Color.Red
Askerion
2013-03-18T14:57:38Z
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
DataGridViewStatus.Rows(1).RowTextCell.BackColor = Color.Blue
DataGridViewStatus.Rows(2).RowTextCell.BackColor = Color.Black
DataGridViewStatus.Rows(3).RowTextCell.BackColor = Color.Red




End Sub

Only the Rows(3) change the color of the header
But for all the header rows

I want each row header in a another color.

and the event is best with a click.

Unfortunately I can not find the command for each row header editing

(see the attachment)
Askerion attached the following image(s):
Igor/10Tec
2013-03-19T09:10:45Z
Oops.. Sorry - my fault. I forgot that when iGrid creates group rows automatically, it assigns the same cell style object to all row text cells with the same hierarchy level. That's why in our code we actually change the background color for all group rows, and only the last setting has the effect.

A sidenote: These cell styles are retrieved from the GroupRowLevelStyles array property you can populate before grouping. By default, it has one item used in all group rows on all levels, but you can define a personal style for each level. This approach allows you to apply the same formatting to all group rows with the same level.

To do it the right way, we need to create a personal style object for every group row:

DataGridViewStatus.Rows(1).RowTextCell.Style = New iGCellStyle()
DataGridViewStatus.Rows(1).RowTextCell.BackColor = Color.Blue

DataGridViewStatus.Rows(2).RowTextCell.Style = New iGCellStyle()
DataGridViewStatus.Rows(2).RowTextCell.BackColor = Color.Black

DataGridViewStatus.Rows(3).RowTextCell.Style = New iGCellStyle()
DataGridViewStatus.Rows(3).RowTextCell.BackColor = Color.Red

***********************

Note also that our .NET DataGridView also has the AfterAutoGroupRowCreated event you can use to apply formatting like this on-the-fly during the grouping process.
Askerion
2013-03-19T10:12:47Z
Hi this works great,

there is also a possibility the number of Grouped Rows read.

example

Grouped Row
under Row
under row
Grouped Row
under Row
Grouped Row
under row
under row

Grouped Rows are 3

引用:

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim i As Integer
Dim z As Integer
Dim b As Integer
i = 0


Do While i < DataGridViewStatus.Rows.Count
'MsgBox(DataGridViewStatus.Rows(i).Cells(0).Value)
'MsgBox(i)

For z = DataGridViewStatus.Cols.Count To 1 Step -1
b = z - 1
If DataGridViewStatus.Rows(i).Cells(b).Value.ToString = "IT" Then
MsgBox(i)
DataGridViewStatus.Rows(i).Cells(b).BackColor = Color.Yellow

DataGridViewStatus.Rows(i).RowTextCell.BackColor = Color.Blue (This works not only because, unfortunately, the value "IT" is always in the bottom row)


Exit For
ElseIf DataGridViewStatus.Rows(i).Cells(b).Value.ToString = "" Then
'DataGridViewStatus.Rows(i).Cells(0).Style.BackColor = Color.Green

End If
Next
i = i + 1
Loop




End Sub

Igor/10Tec
2013-03-19T17:07:13Z
It's not clear from your last post what you need to do, but it seems you are going to colorize group rows based on their contents (cell value). This can be done using the CellDynamicFormatting event. For instance, if you need to use the blue background color for group rows which display the "IT" value, your code might look like this:

Private Sub iGrid1_CellDynamicFormatting(sender As Object, e As iGCellDynamicFormattingEventArgs) Handles iGrid1.CellDynamicFormatting
   If e.ColIndex = -1 Then ' row text cell
      If iGrid1.Cells(e.RowIndex, e.ColIndex).Value = "IT" Then
         e.BackColor = Color.Blue
      End If
   End If
End Sub

P.S. If your cell values are strings, there is no need to convert them to string using the .ToString() method like you do in your code. Just read them through the Value property "as is".