Results 1 to 3 of 3

Thread: [RESOLVED] To list / sort colours with GetBrightness()

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2016
    Posts
    4

    Resolved [RESOLVED] To list / sort colours with GetBrightness()

    With the following codes i added all colours to a combobox (sorted by brightness). It begins automaticaly with the darkest colour and goes to brightest. Is there any way to do it conversely? I mean, it should begin with brightest colour and go to darkest? Thanks in advance


    Private Sub bindWebColorsBrightness()

    cmbColorsBrightness.DrawMode = DrawMode.OwnerDrawFixed
    cmbColorsBrightness.ItemHeight = 20

    Dim ColorName As String
    For Each ColorName In System.Enum.GetNames(GetType(System.Drawing.KnownColor)).OrderBy(Function(kc) Color.FromName(kc).GetBrightness)

    Dim Syscolor As Color = Color.FromName(ColorName)
    If Not Syscolor.IsSystemColor Then
    cmbColorsBrightness.Items.Add(Color.FromName(ColorName))
    End If
    Next
    End Sub

  2. #2
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: To list / sort colours with GetBrightness()

    Among other ways, you could reverse the collection iterated by the For-Next loop:
    Code:
    For Each ColorName In _
    System.Enum.GetNames(GetType(System.Drawing.KnownColor)).OrderBy(Function(kc) Color.FromName(kc).GetBrightness).Reverse
    (scroll to see the end of the line)

    BB

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2016
    Posts
    4

    Re: To list / sort colours with GetBrightness()

    oh so simple, thank you very much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width