Reputation:
How can i format some cell value into something else using DevExpress.XtraGrid.StyleFormatCondition . For example I need to bold some value in one or more cell with same value and how to change only one column not entire row
Here it is my example:
For i As Integer = 0 To GridView1.DataRowCount
Dim a As String = (GridView1.Columns(0)).ToString
If a = "Vrsta računa" Then 'THE NAME OF COLUMN
Dim b = GridView1.GetRowCellValue(i, "accountsType") ' THE NAME OF CELL
If b = "KLASA" Then
Dim condition1 As StyleFormatCondition = New DevExpress.XtraGrid.StyleFormatCondition()
condition1.Appearance.BorderColor = Color.Blue
condition1.Appearance.BackColor = Color.Red
condition1.Appearance.Options.UseBackColor = True
condition1.Appearance.Options.UseBorderColor = True
'***** HOW TO BOLD CELL VALUE *******
condition1.Condition = FormatConditionEnum.Expression
condition1.ApplyToRow = False
condition1.Expression = "[accountsType] = 'KLASA'"
GridView1.FormatConditions.Add(condition1)
ElseIf b = "SINTETIKA" Then
Dim condition1 As StyleFormatCondition = New DevExpress.XtraGrid.StyleFormatCondition()
condition1.Appearance.BorderColor = Color.Blue
condition1.Appearance.BackColor = Color.HotPink
condition1.Appearance.Options.UseBackColor = True
condition1.Appearance.Options.UseBorderColor = True
condition1.Condition = FormatConditionEnum.Expression
condition1.ApplyToRow = False
condition1.Expression = "[accountsType] = 'SINTETIKA'"
' I WANT TO Have an effect on a cell , AND not on entire row
GridView1.FormatConditions.Add(condition1)
ElseIf b = "ANALITIKA" Then
Dim condition1 As StyleFormatCondition = New DevExpress.XtraGrid.StyleFormatCondition()
condition1.Appearance.BorderColor = Color.Blue
condition1.Appearance.BackColor = Color.Green
condition1.Appearance.Options.UseBackColor = True
condition1.Appearance.Options.UseBorderColor = True
condition1.Condition = FormatConditionEnum.Expression
condition1.ApplyToRow = False
condition1.Expression = "[accountsType] = 'ANALITIKA'"
GridView1.FormatConditions.Add(condition1)
End If
End If
Next
Upvotes: 0
Views: 1651
Reputation: 499
It looks like you are using Format Conditions not in a correct way. There is no need to traverse through all rows and columns manually. Before painting each row, GridView automatically checks if it meets any condition in its FormatConditions collection. If so, GridView applies a corresponding style.
Please refer to the following help topic to learn how to use Format Conditions correctly:
https://documentation.devexpress.com/#WindowsForms/CustomDocument759
Upvotes: 1