Groups | Blog | Home
all groups > vb.net controls > november 2004 >

vb.net controls : Runtime Created Buttons


Herfried K. Wagner [MVP]
11/3/2004 11:23:53 AM
"yoshitha" <gudivada_kmm@rediffmail.com> schrieb:
[quoted text, click to view]

\\\
Select Case DirectCast(sender, Button).Name
Case...
...
...
End Select
///

--
Herfried K. Wagner [MVP]
yoshitha
11/3/2004 3:33:57 PM
Hi,
Am creating buttons at runtime , the number of buttons am creating is
depending upon the no of rows in the dataset object.
so i want to perform some action when i click the button.
How can I differenciate the buttons from each other.

see the following code

For i = 0 To count - 1
For pcount = 0 To pcount - 1

If objds.Tables(0).Rows(i)("Patient_id") =
objds1.Tables(0).Rows(pcount)("ID") Then

strPatientname = objds1.Tables(0).Rows(pcount)("fname")

strPatientname = strPatientname & objds1.Tables(0).Rows(pcount)("code")

Exit For

End If

Next

btn.Location = New System.Drawing.Point(x, y)

' btn.Width = strPatientname.Length()

btnPanel.Controls.Add(btn)

btn.Text = strPatientname

y = y + 25

Next

End If

AddHandler btn.Click, AddressOf example

each button is having different caption (and also name) so when i click on
the button based on the caption(text) or name (here i didnt write code to
set the name of the button) it has to retrieve the data.

Here i set the button width to some string length

but when am running the application it is showing only one charater on the
button when I remove that code it is displaying half of the name.

How to write the code for both

Plz tell me

yoshitha





AddThis Social Bookmark Button