Color enum, collection, ...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • msjonathan
    New Member
    • Dec 2009
    • 24

    #1

    Color enum, collection, ...

    Hi,
    I am making a program with multiple grids, the user can drag&drop rows between Grids.
    For visualizing this nice and easy I give each row in a grid an other color.
    For the moment I store the color in a person object but, this is just temporally.

    Code:
    private void gridView2_RowStyle(object sender, RowStyleEventArgs e)
          {
             GridView view = sender as GridView;
    
             if (e.RowHandle >= 0)
                e.Appearance.BackColor = persons[e.RowHandle].color;
          }
    Note this provided code also changes the color again when you click again in a row (still has to change that :) )

    Has anyone an idea how I can automate this withoud using the list of Person object where the color is stored.
    Like a sort of list of colors, enum (int).

    Greetz Jonathan
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    I'm not sure I understand your problem... do you want to store those colours elsewhere, not in the persons object? Do you want a different colour whenever you drag and drop between grids? Sorry, I'm likely not reading it right, can you perhaps clarify?

    I will throw this out there though... you can make an array or list of colours, then do whatever you want with them. For example...

    Code:
     Color[] myColours = new Color[] { Color.Red, Color.Blue, Color.Green, ...};
    If you wanted, you could probably sort that array as well, though you'd probably have to do it via RGB. You can also loop through what an enum provides, check out this link: http://www.csharp-station.com/tutorials/lesson17.aspx

    Comment

    • msjonathan
      New Member
      • Dec 2009
      • 24

      #3
      Hej,

      Thank you for answering. I wanted to create a dynamic list of all colors. I did not want to type all colors in an array or list.

      I dit it like tis if foreached all KnowColors and in the foreach ListOfColors.Ad d(Color.FromKno wColor(....))

      And so I did not have to type all the colors.

      Greetz

      Jonathan

      Comment

      Working...