473,474 Members | 1,304 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Added Checkboxes Dynamically now I want change there state

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 _
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

Mar 9 '06 #1
1 1235
"Dan H" <da*******@gmail.com> schrieb
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 f_checkboxes as checkbox()

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.

redim f_checkboxes(IFK.GetNumInputs - 1)

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)

f_checkboxes(i) = 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)

f_checkboxes(e.getIndex).checked = ...

End Sub

End Class


Armin
Mar 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: DJ Dev | last post by:
Hi All, I have a complex problem. I have dropdownlists (usually 3-5) and the user selects some value from these and for each value selected, datagrids are shown to the user. I am creating the...
2
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to...
1
by: Dan H | last post by:
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...
0
by: Dan H | last post by:
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...
1
by: Kevin R | last post by:
This is one of the weirdest problems I have ever run into. I have had to trim down a bunch of code to give a sample that is more easily readable by those who will view this. Here is the problem:...
0
by: Mike Collins | last post by:
I someone can please help, I am about at an end in trying to figure this out. I am adding some dynamic controls to my page (I found out that I was supposed to be doing that in the oninit event,...
8
by: mark.norgate | last post by:
I've asked this question before, but still haven't solved it, so am asking again. I am programmatically adding a user control to the page in response to a button click. The user control consists...
8
by: SalamElias | last post by:
I create 2 groupes of checkboxes dynamically (I don't use checkboxlist) for 2 differnet zones in my aspx web page and I assign a "onClick" javascript handler by group., lets say the first 4 chboxes...
10
by: rn5a | last post by:
All the rows in a DataGrid, including the Header, are accompanied with a CheckBox. I want that when the CheckBox in the Header is checked, then all the CheckBoxes should automatically get checked....
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.