I am adding a seriese of controls to 'panel1' on 'form1' This works well but
I can't find a way to enable events. This example adds a 10 x 10 grid of
check boxes.
How can I create an event that will run if any of the check boxes are ticked.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim x As Integer
Dim y As Integer
Dim pt As New System.Drawing.Point
Dim sz As New System.Drawing.Size
For x = 1 To 10
For y = 1 To 10
pt.X = x * 25 : pt.Y = y * 25
sz.Height = 17 : sz.Width = 17
myBox(x, y) = New CheckBox
If x = 1 And y = 1 Then myBox(1, 1) = cb
Panel1.Controls.Add(myBox(x, y))
With myBox(x, y)
.Text = ""
.Location = pt
.Size = sz
End With
Next y
Next x
Dim lbl As New LinkLabel
pt.X = 37 : pt.Y = 280
lbl.Text = "JF"
lbl.Location = pt
Panel1.Controls.Add(lbl)
End Sub 3 782
"John F" <Jo***@discussions.microsoft.com> schrieb I am adding a seriese of controls to 'panel1' on 'form1' This works well but I can't find a way to enable events. This example adds a 10 x 10 grid of check boxes.
How can I create an event that will run if any of the check boxes are ticked.
[...] myBox(x, y) = New CheckBox
AddHandler mybox(x,y).CheckedChanged, addressof _____ 'Insert Name of
event handler
BTW, this is also explained in the docs: http://msdn.microsoft.com/library/en...nheritance.asp
(also available via <F1>)
Armin
Hi you can use addhandler for that
for example
Private Sub CheckBox_CheckedChanged(ByVal sender As Object, ByVal e As
System.EventArgs)
msgbox(directcast(sender,CheckBox).Checked)
End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim x As Integer Dim y As Integer Dim pt As New System.Drawing.Point Dim sz As New System.Drawing.Size
Dim myChk As CheckBox
For x = 1 To 10 For y = 1 To 10
myChk = New CheckBox
AddHandler myChk.CheckedChanged, AddressOf
CheckBox_CheckedChanged pt.X = x * 25 : pt.Y = y * 25 sz.Height = 17 : sz.Width = 17
With myChk
.Text = ""
.Location = pt
.Size = sz
End With
myBox(x, y) = myChk
Panel1.Controls.Add(myChk) Next y Next x Dim lbl As New LinkLabel pt.X = 37 : pt.Y = 280 lbl.Text = "JF" lbl.Location = pt Panel1.Controls.Add(lbl) End Sub
Hth Greetz Peter
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)
"John F" <Jo***@discussions.microsoft.com> schreef in bericht
news:C5**********************************@microsof t.com... I am adding a seriese of controls to 'panel1' on 'form1' This works well
but I can't find a way to enable events. This example adds a 10 x 10 grid of check boxes.
How can I create an event that will run if any of the check boxes are
ticked. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim x As Integer Dim y As Integer Dim pt As New System.Drawing.Point Dim sz As New System.Drawing.Size For x = 1 To 10 For y = 1 To 10 pt.X = x * 25 : pt.Y = y * 25 sz.Height = 17 : sz.Width = 17 myBox(x, y) = New CheckBox If x = 1 And y = 1 Then myBox(1, 1) = cb Panel1.Controls.Add(myBox(x, y)) With myBox(x, y) .Text = "" .Location = pt .Size = sz End With Next y Next x Dim lbl As New LinkLabel pt.X = 37 : pt.Y = 280 lbl.Text = "JF" lbl.Location = pt Panel1.Controls.Add(lbl) End Sub
Thanks Armin, Peter.
Exactly what I was lookin for.
John. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: melledge |
last post by:
Full Programme for XTech 2005 Announced
Premier European XML Industry Event Expands Focus to "XML, the Web and
Beyond";
Co-hosted by the Mozilla Foundation,W3C, and OASIS, Presenters Include...
|
by: dave |
last post by:
Hi, I have a COM control / server I'm trying to get events from in my c#
applications.
1) I'm trying to get events in both c# console apps and in c# winform apps.
2) I can call methods on the...
|
by: Earl Teigrob |
last post by:
PROBLEM:
When a user control is loaded into a PlaceHolder control more than once, the
events do not fire on the first click of a control on the dynamically loaded
user control. In other words, the...
|
by: John Lau |
last post by:
Hi,
Is there documentation that talks about the page lifecycle, the lifecycle of
controls on the page, and the rendering of inline code, in a single
document?
Thanks,
John
|
by: Martin |
last post by:
Hi,
I have produced a custom server control that simple outputs a row of 26
buttons, one button for each letter of the english alphabet.
now what I would like to do is catch the button click...
|
by: gvrr |
last post by:
Hello,
I would like to know what are the basic require that I should be familiar within VB6 for creating a QUIZ programme (standalone) which can be
a) an executable
b) should access a DATA...
|
by: arnuld |
last post by:
i compiled the "hello world" programme from K&R2:
#include<stdio.h>
int main() {
printf("hello world\n");
}
|
by: chang |
last post by:
Hi ALL,
I am working in C from past few months. Still now i can't
figure out who is called main() in 'C' programme?
Main() is a function from that we can call our sunroutines but someone
has to...
|
by: Rex the Strange |
last post by:
Hello All,
I don't know if this is possible, but I'll give it a shot, here. I'm
sick of writing the following line of code in control event handlers:
if not visible then exit sub
Is it...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
| |