This is a migrated thread and some comments may be shown as answers.

Multiselect, change backgroundcolor after select on other rows

1 Answer 133 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Beth
Top achievements
Rank 1
Beth asked on 05 Nov 2012, 08:17 PM
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
          Else
              mylistitem.Attributes.Add("style", "background-color:#FFFFFF")
          End If
      Next
  End Sub

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Nov 2012, 05:21 AM
Hi Beth,

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

VB:
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
    Next
End Sub

Thanks,
Princy.
Tags
ComboBox
Asked by
Beth
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or