Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
ultra grid rows color change
posted

Hi. I am a beginner.
c# ultragrid row try backcolor change but it not change. what should i do?
I searched the internet and tried various methods.

What I want is to change the background color of the row that contains the specific value each time I make a selection.

I have applied a variety of codes. The color was still visible only when you put the gradient effect.
But I do not want gradations.

I hope you have someone who can help me.

  • 34430
    Suggested Answer
    Offline posted

    Hello sujeong,

    I have been investigating your requirement in this case, and it sounds like you are looking to either set the row colors for each row in the UltraGrid or you are trying to set the selected row's color, specifically. This is the impression that I am under from your original description. If it is inaccurate to what you are trying to do, then would it be possible for you to please provide some additional detail on what your requirement is in this case?

    In order to set the row background or the selected row background, I would recommend using the DisplayLayout.Override.RowAppearance.BackColor and DisplayLayout.Override.SelectedRowAppearance.BackColor properties off of the UltraGrid. For example, to set these colors to LightGray and Red, respectively, you could use the following:

    ultraGrid1.DisplayLayout.Override.RowAppearance.BackColor = Color.LightGray;
    ultraGrid1.DisplayLayout.Override.SelectedRowAppearance.BackColor = Color.Red;

    This will color the rows light gray when they are in their normal, default state and red when they are selected. I am attaching a sample project to demonstrate the above. I hope this helps you.

    Please let me know if you have any other questions or concerns on this matter.

    UltraGridRowColoringDemo.zip

  • 469350
    Offline posted

    Another option to consider is to use the selection overlay. This provides you with a semi-transparent overlay on top of the selected rows or cells. That way, if you have cells or rows to which a color has been applied, you can still see the row/cell color through the selection overlay. 

    You can use selection overlay by just setting a color: 

    this.ultraGrid1.DisplayLayout.SelectionOverlayColor = SystemColors.Highlight;

    You could also, optionally, add a border around the selection: 

    this.ultraGrid1.DisplayLayout.SelectionOverlayBorderColor = Color.Black;
    this.ultraGrid1.DisplayLayout.SelectionOverlayBorderThickness = 1;

  • 225
    Suggested Answer
    Offline posted

    In the InitializeRow  event of the grid you can put a condition to set the .BackColor property of the color of your choice.

    I hope this help you.

    Alejandro Castyrejon