|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
through the first combo box always report back correctly its when i move to the next combobox, that instead of changing the second combo box it will change the background of the first combo box. What im i doing wrong? For intloop = 0 To cboArraylist.Count - 1 If (CType(cboArraylist(intloop), ComboBox).Text) = "Go" Then CType(cboArraylist(intloop), Object).BackColor = Color.LawnGreen ElseIf (CType(cboArraylist(intloop), ComboBox).Text) = "No Go" Then CType(cboArraylist(intloop), Object).BackColor = Color.Tomato End If Next
Show quote
Hide quote
"cmdolcet69" <colin_dolce***@hotmail.com> schrieb First, you should enable Option Strict. I can not compile your code because> I need to loop through a index change event, however whenever i loop > through the first combo box always report back correctly its when i > move to the next combobox, that instead of changing the second combo > box it will change the background of the first combo box. > > What im i doing wrong? > > For intloop = 0 To cboArraylist.Count - 1 > If (CType(cboArraylist(intloop), ComboBox).Text) = "Go" > Then > CType(cboArraylist(intloop), Object).BackColor = > Color.LawnGreen > ElseIf (CType(cboArraylist(intloop), ComboBox).Text) = > "No Go" Then > CType(cboArraylist(intloop), Object).BackColor = > Color.Tomato > End If > > Next the Object data type does not have a BackColor property. After correcting the error and creating an executable project, I can not reproduce the problem. Each Combobox gets it's individual color. How did you add the comboboxes to the Arraylist? Maybe you added the same Combobox multiple times. Armin My guess is that the problem is in your ArrayList. Why don't you show us the
code that loads the list. Also, may I suggest... Dim cbo as ComboBox For intloop = 0 To cboArraylist.Count - 1 cbo = CType(cboArraylist(intloop), ComboBox) if cbo.Text = "Go" then cbo.BackColor = Color.LawnGreen ElseIf cbo.Text = "No Go" then cbo.BackColor = Color.Tomato End If Next To me, this is much easier to read and is more effecient. -- Show quoteHide quoteTerry "cmdolcet69" wrote: > I need to loop through a index change event, however whenever i loop > through the first combo box always report back correctly its when i > move to the next combobox, that instead of changing the second combo > box it will change the background of the first combo box. > > What im i doing wrong? > > For intloop = 0 To cboArraylist.Count - 1 > If (CType(cboArraylist(intloop), ComboBox).Text) = "Go" > Then > CType(cboArraylist(intloop), Object).BackColor = > Color.LawnGreen > ElseIf (CType(cboArraylist(intloop), ComboBox).Text) = "No > Go" Then > CType(cboArraylist(intloop), Object).BackColor = > Color.Tomato > End If > > Next > cm,
As soon as you change the index, then the index event is thrown. You can use a switch or what I like more is setting the eventhandler off at the begin and add it again at the end of your method. Cor |
|||||||||||||||||||||||