Home Forums WinForms controls Xceed Grid for WinForms Disable selection colors?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #13627 |

    Hey,

    Is it possible, without subclassing the DataRow class, to paint even selected rows with their own background color? If not, I assume it’s DataRow that I should subclass?

    Imported from legacy forums. Posted by macke (had 3508 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Marcus,

    You could set the SelectionBackColor property to the desired color. All the selected rows will then have this background color when they are selected. If you want selected rows to have different colors depending on their content, you could use the SelectedRowsChanged event.

    The foreground color of the selected rows can be changed using the SelectionForeColor property.

    I hope this helps.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 316 views)

    User (Old forums)
    Member
    Post count: 23064

    But if the user has selected more than one row, and I want each of the rows to show their own background color (ie, the same as not painting a SelectedBackColor at all, but leaving the default paint behaviour), will catching said event help at all? Or did you mean something other than setting SelectionBackColor to some value when the SelectedRowsChanged event gets fired?

    I’m basicly coloring rows from Green to Red based on their relevance when the user has searched the database for a certain value. Green in this case means 100% relevance and Red means 0% relevance, and of course anything in between being between 0 and 100%.

    This is why I would like to disable the SelectedBackColor from being painted (or something which gives the same effect) and only have the little focus rectangle showing in the row to tell the user what row is selected.

    Imported from legacy forums. Posted by macke (had 438 views)

    User (Old forums)
    Member
    Post count: 23064

    Do you mean the <b>selected rows</b> or the <b>current row</b>? There can be multiple selected rows, but only 1 current row.

    Imported from legacy forums. Posted by Tommy (had 175 views)

    User (Old forums)
    Member
    Post count: 23064

    Yes, I meant selected rows. I’m sorry if I wasn’t clear on that, I don’t think I mentioned current row. But anyways, yes, I do mean selected rows.

    I subclassed DataRow (no painting) and DataCell (painting) and actually landed sort of in the middle of no painting and painting, alpha blending. I Actually first draw the background color and then draw a transparent color on top of that. I’m not sure what the performance drawbacks of this is, but i’m pretty sure that it’s not a good thing. Since I’m not using any textures but rather solid backgrounds, I could simply just calculate a new color and only paint the background once, with this color. I’m guessing that will be faster. Either way, I’m simply prototyping right now so it doesn’t matter as long as the end result is the same.

    I do however have a question following this. When setting values in a cell or row template, these values are then to be used to set my custom properties in the constructor that takes a template as parameter?

    Imported from legacy forums. Posted by macke (had 4789 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.