Posted 27 February 2024, 8:02 pm EST
Hello Florent,
Apologies for the delayed response.
We are sorry, but there is no direct way to change the color of the C1SplitButton’s arrow. You will have to use a C1Theme. For more information on creating and using a C1Theme please refer to https://developer.mescius.com/componentone/docs/win/online-themes/QSCreatingaCustomTheme.html#step2.
You can change the color of the arrow programmatically as follows:
// Get theme by name.
var theme = C1ThemeController.GetThemeByName("MyTheme", false);
if (theme != null)
{
// Get the color property at the specified path.
if (theme.Children.GetItemByPath("C1Input\\C1SplitButton\\Buttons\\Default\\ArrowColor") is ColorProp prop)
{
prop.Value = Color.FromArgb(_rnd.Next(256), _rnd.Next(256), _rnd.Next(256));
}
C1ThemeController.ApplyThemeToControlTree(this, theme);
}
To change the cell border’s color, you can utilize the Border property in CellStyle. Refer to the below code to see how to set the border color if the value is correct (in the editable column) in the AfterEdit event:
[code]//add style for editable column
var style = c1FlexGrid1.Styles.Add(“editable”);
style.Border.Color = Color.LightBlue;
style.Border.Width = 2;
c1FlexGrid1.Cols[“editable”].Style = style;
//add a style for correctValues
style = c1FlexGrid1.Styles.Add(“correctVal”);
style.Border.Color = Color.LightGreen;
style.Border.Width = 2;
private void C1FlexGrid1_AfterEdit(object sender, C1.Win.C1FlexGrid.RowColEventArgs e)
{
if(e.Col == c1FlexGrid1.Cols[“editable”].Index)
{
if (int.TryParse(c1FlexGrid1[e.Row, e.Col].ToString(), out _))
{
c1FlexGrid1.SetCellStyle(e.Row, e.Col, c1FlexGrid1.Styles[“correctVal”]);
}
else
{
c1FlexGrid1.SetCellStyle(e.Row, e.Col, c1FlexGrid1.Styles[“incorrectVal”]);
}
}
}[/code]
In the sample, we have set styles for editable or non-editable columns. If you intend to set style for specific cells only, then you can use SetCellStyle() for each cell or cell range.
If you want to display a border over a complete cell, then you’ll have to use the OwnerDrawCell event to draw borders manually.
Please refer to the attached sample for implementation. (see FlexGrid_SplitButton.zip)
Regards,
Uttkarsh.