|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
programatically created checkboxes within panels again....I have some programatically created checkboxes within a panel how can i set a checkbox to be actually checked (i.e. change its state) currently im doing the following: While count < DS4.Tables(0).Rows.Count While count2 < Me.Panel2.Controls.Count If DS4.Tables(0).Rows(count)(0) = Me.Panel2.Controls.Item(count2).Text.ToString Then 'NEED SOME CODE TO SET THE CHECKBOX WITHIN THE PANEL TO CHECKED End If count2 = count2 + 1 End While count2 = 0 count = count + 1 End While Basically im looping through a dataset to see if the value in the dataset is the same as the text on a checkbox, if it is i need to set the checkbox to checked, but i have no idea how to do it Thanks Mike Fellows I managed to do this, very simply in all honesty
by doing the following Dim cbx As CheckBox cbx = Me.Panel2.Controls.Item(count2) cbx.Checked = True Me.Panel2.Controls.RemoveAt(count2) Me.Panel2.Controls.Add(cbx) Thanks though Show quoteHide quote "Mike Fellows" <michael.fellows@equityhouse.NOSPAM.co.uk> wrote in message news:yLqdnZInO9L80irZnZ2dneKdnZydnZ2d@giganews.com... > ok guys you have been a great help so far with this but im still > struggling > > I have some programatically created checkboxes within a panel > > how can i set a checkbox to be actually checked (i.e. change its state) > > currently im doing the following: > > > While count < DS4.Tables(0).Rows.Count > While count2 < Me.Panel2.Controls.Count > If DS4.Tables(0).Rows(count)(0) = > Me.Panel2.Controls.Item(count2).Text.ToString Then > > 'NEED SOME CODE TO SET THE CHECKBOX WITHIN THE PANEL TO CHECKED > > End If > count2 = count2 + 1 > End While > count2 = 0 > count = count + 1 > End While > > Basically im looping through a dataset to see if the value in the dataset > is the same as the text on a checkbox, if it is i need to set the checkbox > to checked, but i have no idea how to do it > > Thanks > > Mike Fellows > Hi Mike,
In your code, cbx and Me.Panel2.Controls.Items(count2) are references to the same object - what is the point in removing and then adding the same checkbox to the collection? Why don't you just: Ctype(Me.Panel2.Controls.Items(count2), CheckBox).Checked = True -- Show quoteHide quoteTerry "Mike Fellows" wrote: > I managed to do this, very simply in all honesty > > by doing the following > > Dim cbx As CheckBox > cbx = Me.Panel2.Controls.Item(count2) > cbx.Checked = True > Me.Panel2.Controls.RemoveAt(count2) > Me.Panel2.Controls.Add(cbx) > > > > Thanks though > > > > > > "Mike Fellows" <michael.fellows@equityhouse.NOSPAM.co.uk> wrote in message > news:yLqdnZInO9L80irZnZ2dneKdnZydnZ2d@giganews.com... > > ok guys you have been a great help so far with this but im still > > struggling > > > > I have some programatically created checkboxes within a panel > > > > how can i set a checkbox to be actually checked (i.e. change its state) > > > > currently im doing the following: > > > > > > While count < DS4.Tables(0).Rows.Count > > While count2 < Me.Panel2.Controls.Count > > If DS4.Tables(0).Rows(count)(0) = > > Me.Panel2.Controls.Item(count2).Text.ToString Then > > > > 'NEED SOME CODE TO SET THE CHECKBOX WITHIN THE PANEL TO CHECKED > > > > End If > > count2 = count2 + 1 > > End While > > count2 = 0 > > count = count + 1 > > End While > > > > Basically im looping through a dataset to see if the value in the dataset > > is the same as the text on a checkbox, if it is i need to set the checkbox > > to checked, but i have no idea how to do it > > > > Thanks > > > > Mike Fellows > > > > > Because I didnt know how to do that
but that is much better than my way Thanks Show quoteHide quote "Terry" <Terry@nospam.nospam> wrote in message news:58378FE8-F149-4FA9-9ED0-D85A1F89E619@microsoft.com... > Hi Mike, > In your code, cbx and Me.Panel2.Controls.Items(count2) are references to > the same object - what is the point in removing and then adding the same > checkbox to the collection? > Why don't you just: > Ctype(Me.Panel2.Controls.Items(count2), CheckBox).Checked = True > > -- > Terry > > > "Mike Fellows" wrote: > >> I managed to do this, very simply in all honesty >> >> by doing the following >> >> Dim cbx As CheckBox >> cbx = Me.Panel2.Controls.Item(count2) >> cbx.Checked = True >> Me.Panel2.Controls.RemoveAt(count2) >> Me.Panel2.Controls.Add(cbx) >> >> >> >> Thanks though >> >> >> >> >> >> "Mike Fellows" <michael.fellows@equityhouse.NOSPAM.co.uk> wrote in >> message >> news:yLqdnZInO9L80irZnZ2dneKdnZydnZ2d@giganews.com... >> > ok guys you have been a great help so far with this but im still >> > struggling >> > >> > I have some programatically created checkboxes within a panel >> > >> > how can i set a checkbox to be actually checked (i.e. change its state) >> > >> > currently im doing the following: >> > >> > >> > While count < DS4.Tables(0).Rows.Count >> > While count2 < Me.Panel2.Controls.Count >> > If DS4.Tables(0).Rows(count)(0) = >> > Me.Panel2.Controls.Item(count2).Text.ToString Then >> > >> > 'NEED SOME CODE TO SET THE CHECKBOX WITHIN THE PANEL TO >> > CHECKED >> > >> > End If >> > count2 = count2 + 1 >> > End While >> > count2 = 0 >> > count = count + 1 >> > End While >> > >> > Basically im looping through a dataset to see if the value in the >> > dataset >> > is the same as the text on a checkbox, if it is i need to set the >> > checkbox >> > to checked, but i have no idea how to do it >> > >> > Thanks >> > >> > Mike Fellows >> > >> >> >>
Calling Sub Procedure with a variable
ISO-8859-1 encoding of an xml string Deleting a Photo stored in a Picturebox VB.NET 2002 question from complete and utter newbie to programming Old Basic commands. Lauching a form from another form consume web service via httpwebrequest How to remove an empty array ? Strict type for Hashtable? Dataset to excel |
|||||||||||||||||||||||