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(ByVa l sender As System.Object, ByVal e As _
System.EventArg s) Handles MyBase.Load
End Sub
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeCompo nent()
' Add any initialization after the InitializeCompo nent() call.
For i As Integer = 0 To IFK.GetNumInput s - 1
Dim chkInput As New CheckBox
chkInput.Locati on = New Drawing.Point(1 10, 170 + i * 20)
chkInput.TabInd ex = i
chkInput.Tag = i.ToString
chkInput.Name = "input" + i.ToString
chkInput.Text = chkInput.Tag.To String
AddHandler chkInput.Click, AddressOf ClickInputs
Controls.Add(ch kInput)
Next
End Sub
Private Sub ClickInputs(ByV al sender As Object, ByVal e As
EventArgs)
MessageBox.Show ("Clicked was " & DirectCast(send er,
CheckBox).Tag.T oString)
End Sub
Private Sub IFK_InputChange (ByVal sender As Object, ByVal e As _
InputChangeEven tArgs) Handles IFK.InputChange
MessageBox.Show (e.getIndex & " is " & e.getState)
End Sub
End Class 1 2728
Dan,
You mean something as beneath typed in this message so watch typos.
\\\
Public sub SetCheckBox(byv al chkstate as Boolean, byval checkboxindex as
integer)
For each ctr as Control in me.controls
if Typeof ctr Is CheckBox then
dim chk as checkbox = ctr
if chk.name = "input" & checkboxindex.t ostring then
chk.checked = chkstate
end if
end if
end for
///
(You can as well create an arraylist of refrences to the textboxes you use
global in your program)
I hope this helps,
Cor
"Dan H" <da*******@gmai l.com> schreef in bericht
news:11******** **************@ i39g2000cwa.goo glegroups.com.. . 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(ByVa l sender As System.Object, ByVal e As _ System.EventArg s) Handles MyBase.Load
End Sub
Public Sub New() ' This call is required by the Windows Form Designer. InitializeCompo nent() ' Add any initialization after the InitializeCompo nent() call. For i As Integer = 0 To IFK.GetNumInput s - 1 Dim chkInput As New CheckBox chkInput.Locati on = New Drawing.Point(1 10, 170 + i * 20) chkInput.TabInd ex = i chkInput.Tag = i.ToString chkInput.Name = "input" + i.ToString chkInput.Text = chkInput.Tag.To String AddHandler chkInput.Click, AddressOf ClickInputs Controls.Add(ch kInput) Next
End Sub
Private Sub ClickInputs(ByV al sender As Object, ByVal e As EventArgs) MessageBox.Show ("Clicked was " & DirectCast(send er, CheckBox).Tag.T oString) End Sub
Private Sub IFK_InputChange (ByVal sender As Object, ByVal e As _ InputChangeEven tArgs) Handles IFK.InputChange MessageBox.Show (e.getIndex & " is " & e.getState) End Sub
End Class This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: RodBillett |
last post by:
I have a situation where I have 3 checkboxes - and at least 1 needs to be
selected at all times...
I have implemented the code that allows this behavior to happen, BUT
Viewstate gets all messed up. As long as none of the checkboxes are
disabled, viewstate works fine - and client actions are 'remembered' after a
postback. but when I have one checkbox and it is disabled, then when I
postback, ALL checkboxes get the unchecked value.
...
|
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 Datagrids
dynamically using a loop depending on the number of Dropdownlists. The
datagrids also have a checkbox template column. Now my problem is that
how can I access the values selected by the user from these
checkboxes. He checks one or more...
|
by: Scott P. |
last post by:
I'm creating an app using ASP .NET (my second app so bear with me here) that
basically builds a PDF file based on a bunch of user selections. I have a
page which displays a series of checkboxs using the checkbox object. These
are all created on-the-fly using the following code:
While dtrSelect.Read
Dim DocumentRow As New TableRow
Dim DocumentCell As New TableCell
Dim DocumentCell1 As New TableCell
Dim chkDocument As CheckBox
|
by: Alexander Mueller |
last post by:
Hi all,
in a CheckedListBox there are afaics two members that change the
checked-flag for an item i.e. SetItemChecked and SetItemCheckState.
In the online-help there is a remark that SetItemCheckState will raise
an ItemCheck-event. There is no such remark for SetItemChecked also
it also raises this event in a small testcase.
Is there any differnce between the two methods except that
SetItemCheckState allows setting the...
|
by: Pete Moss |
last post by:
During a postback event, I am having trouble retrieving the state of a
CheckBox Control that I am dynamically adding to a DataGrid Control using
ASP.NET 1.1.
I have no trouble adding the TemplateColumn dynamically. I persist a DataSet
in my Session object and I bind the CheckBox to the DataSet. So far so good.
The CheckBoxes show up and the user interacts with them (checks a few,
unchecks a few).
The problem is that during a postback...
| |
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:
I dynamically add an htmlcheckbox to a webform in the pages render and set
the checked value to true. When the page loads, if I remove the check from
the checkbox and then submit it, in the submit event the checkbox' checked
value is still...
|
by: cyberdawg999 |
last post by:
Greetings all in ASP land
I have overcome one obstacle that took me 2 weeks to overcome and I
did it!!!!!
I am so elated!! thank you to all who invested their time and energy towards helping me with my problems.
Now for my new little problem,I had a problem posting the values from checkbox fields to a database and thats the obstacle I overcame.
Now the second part is my new problem is that I want that the next time that page loads for...
|
by: J |
last post by:
I'm dynamically adding checkboxes in the Page_Load (regardless of PostBack).
When IsPostBack, the checkboxes display as I expected and their
checked/unchecked status is also as expected. At this point, I want to find
particular checkboxes and determine whether they are check/unchecked, but
the code only returns that all the checkboxes are unchecked.
void SaveModel(Control parent)
{
// spin through controls recursively
foreach (Control...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |