|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Added Checkboxes Dynamically now I want change there stateAnd I can get the Click event working beautifully. But now I want to use an another event to change the state of the check box but I can seem to figure out how to work with the control. So in the code below I create a bunch of check boxes and I want the event called IFK_InputChange (where I have an external hardware device that I use as IFK, it works no problems) to update the chkInput check boxes that I have created. Any suggestions would be appreciated. Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _ System.EventArgs) Handles MyBase.Load End Sub Public Sub New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. For i As Integer = 0 To IFK.GetNumInputs - 1 Dim chkInput As New CheckBox chkInput.Location = New Drawing.Point(110, 170 + i * 20) chkInput.TabIndex = i chkInput.Tag = i.ToString chkInput.Name = "input" + i.ToString chkInput.Text = chkInput.Tag.ToString AddHandler chkInput.Click, AddressOf ClickInputs Controls.Add(chkInput) Next End Sub Private Sub ClickInputs(ByVal sender As Object, ByVal e As EventArgs) MessageBox.Show("Clicked was " & DirectCast(sender, CheckBox).Tag.ToString) End Sub Private Sub IFK_InputChange(ByVal sender As Object, ByVal e As _ InputChangeEventArgs) Handles IFK.InputChange MessageBox.Show(e.getIndex & " is " & e.getState) End Sub End Class
Show quote
Hide quote
"Dan H" <dan.he***@gmail.com> schrieb private f_checkboxes as checkbox()> I have been able to add controls dyanmically to a windows > application. And I can get the Click event working beautifully. But > now I want to use an another event to change the state of the check > box but I can seem to figure out how to work with the control. > > So in the code below I create a bunch of check boxes and I want the > event called IFK_InputChange (where I have an external hardware > device that I use as IFK, it works no problems) to update the > chkInput check boxes that I have created. > > Any suggestions would be appreciated. > > > > Public Class Form1 > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _ redim f_checkboxes(IFK.GetNumInputs - 1)> System.EventArgs) Handles MyBase.Load > > End Sub > > Public Sub New() > ' This call is required by the Windows Form Designer. > InitializeComponent() > ' Add any initialization after the InitializeComponent() call. > For i As Integer = 0 To IFK.GetNumInputs - 1 f_checkboxes(i) = chkInput> Dim chkInput As New CheckBox > chkInput.Location = New Drawing.Point(110, 170 + i * 20) > chkInput.TabIndex = i > chkInput.Tag = i.ToString > chkInput.Name = "input" + i.ToString > chkInput.Text = chkInput.Tag.ToString > AddHandler chkInput.Click, AddressOf ClickInputs > Controls.Add(chkInput) Show quoteHide quote > Next f_checkboxes(e.getIndex).checked = ...> > End Sub > > Private Sub ClickInputs(ByVal sender As Object, ByVal e As > EventArgs) > MessageBox.Show("Clicked was " & DirectCast(sender, > CheckBox).Tag.ToString) > End Sub > > Private Sub IFK_InputChange(ByVal sender As Object, ByVal e As _ > InputChangeEventArgs) Handles IFK.InputChange > MessageBox.Show(e.getIndex & " is " & e.getState) > End Sub Armin> > End Class
Can't modify instance of a class from within the class!
creating independant application vb 2005 express edition Can you insert elements into an XML file that exists as a string? MIDI guitar sheet music player in .net Access digital camera How to.... Question..... Refresh my memory on datatables, datasets etc. Enum and FlagsAttribute Changing the checked state of Dynamically added checkboxes Retrieving 1 large sql record - progress bar possible? vb.net 2005 sql2000 |
|||||||||||||||||||||||