Multiselect, change backgroundcolor after select on other rows

2 posts, 0 answers
  1. Beth
    Beth avatar
    2 posts
    Member since:
    Oct 2012

    Posted 05 Nov 2012 Link to this post

    Hi need a point in the right direction for an example that will help me do what I need.

    I have a radcombobox that is multiselect, using templates.  When I select an item, I need to go through and either a) select other items or b) highlight other items with a changed back color. 

    Any direction welcome!

    What i was doing prior, was the following on selectedindexchanged on a listbox:
    Protected Sub ChangeBackColorIfImplied()
          Dim SelectedNum As Integer = -1
          Dim SelectedString As String = ""
          Dim StringofUps As String = ""
          lblUpInfo.Text = ""
          Dim i As Integer
          For i = 1 To lbUp.Items.Count - 1
              If lbUp.Items(i).Selected Then
                  StringofUps = StringofUps & lbUp.Items(i).Value
                  lbUp.Items(i).Attributes.Add("style", "background-color#FFFFFF")
              End If
          Next i
          Dim Flag As Boolean = False
          Dim mylistitem As ListItem
          For Each mylistitem In lbUp.Items
              Dim ListItemString As String = mylistitem.Value
              If InStr(StringofUps, ListItemString) > 0 Then
                  If StringofUps <> ListItemString Then
                      mylistitem.Attributes.Add("style", "background-color:#99FFFF")
                      lblUpInfo.Text = "All entities and people highlighted in light blue will also receive this communication"
                  End If
                  mylistitem.Attributes.Add("style", "background-color:#FFFFFF")
              End If
      End Sub
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Nov 2012 Link to this post

    Hi Beth,

    Try the following code to change the background color of all items of a RadCombobox which are not selected.

    Protected Sub lbUp_SelectedIndexChanged(sender As Object, e As RadComboBoxSelectedIndexChangedEventArgs)
        Dim i As Integer = 0
        For i = 0 To lbUp.Items.Count - 1
            Dim StringofUps As String = ""
            If Not lbUp.Items(i).Selected Then
                StringofUps = StringofUps + lbUp.Items(i).Value
                lbUp.Items(i).BackColor = System.Drawing.Color.Yellow
            End If
    End Sub

Back to Top