Can anyone help me out? I am trying to add buttons numbered one
through 10 at runtime to a form.
I think they are getting added but they seem to be getting stacked one
on top of each other. so I only see 1, and not the others.
here is what I am doing can anyone tell me what I am doing wrong?
Public Class Form1
Public buttons(9) As Button
Const buttonwh As Integer = 30
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim i, j, row As Integer
Dim pntcurrent As Point
For i = 0 To 9
j = i + 1
pntcurrent = New Point(j + (buttonwh + 8), row)
Call createbuttons(i, pntcurrent)
Next
For k As Integer = 0 To buttons.GetUpperBound(0)
AddHandler buttons(k).Click, AddressOf Button_click
Next
End Sub
Private Sub createbuttons(ByVal i As Integer, _
ByVal pnt As Point)
buttons(i) = New Button
buttons(i).Enabled = True
buttons(i).Visible = True
buttons(i).Text = Convert.ToString(i + 1)
buttons(i).Size = New _
System.Drawing.Size(buttonwh, buttonwh)
buttons(i).Location = pnt
Me.Controls.Add(buttons(i))
End Sub
Private Sub button_click(ByVal sender As System.Object, _
ByVal e As System.EventArgs)
End Sub
End Class 3 1510
What is row suppose to be? It's always 0. How about something like this:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim i, row As Integer
Dim pntcurrent As Point
row = 30
For i = 0 To 9
pntcurrent = New Point((buttonwh + 8), row * i)
Call createbuttons(i, pntcurrent)
Next
For k As Integer = 0 To buttons.GetUpperBound(0)
AddHandler buttons(k).Click, AddressOf button_click
Next
End Sub
"Ron" <pt*****@yahoo.comwrote in message
news:11**********************@d57g2000hsg.googlegr oups.com...
Can anyone help me out? I am trying to add buttons numbered one
through 10 at runtime to a form.
I think they are getting added but they seem to be getting stacked one
on top of each other. so I only see 1, and not the others.
here is what I am doing can anyone tell me what I am doing wrong?
Public Class Form1
Public buttons(9) As Button
Const buttonwh As Integer = 30
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim i, j, row As Integer
Dim pntcurrent As Point
For i = 0 To 9
j = i + 1
pntcurrent = New Point(j + (buttonwh + 8), row)
Call createbuttons(i, pntcurrent)
Next
For k As Integer = 0 To buttons.GetUpperBound(0)
AddHandler buttons(k).Click, AddressOf Button_click
Next
End Sub
Private Sub createbuttons(ByVal i As Integer, _
ByVal pnt As Point)
buttons(i) = New Button
buttons(i).Enabled = True
buttons(i).Visible = True
buttons(i).Text = Convert.ToString(i + 1)
buttons(i).Size = New _
System.Drawing.Size(buttonwh, buttonwh)
buttons(i).Location = pnt
Me.Controls.Add(buttons(i))
End Sub
Private Sub button_click(ByVal sender As System.Object, _
ByVal e As System.EventArgs)
End Sub
End Class
Ah yes that did it. thank you!
Now what if I wanted to be able to tell what button was being pressed
and know the value of it? Say I want to add a label called
labelbuttons and I want its text property to show 2 if I press
button 2, 3 if i press button three etc?
How would I do this? I just want to make sure that the correct button
referance is there for each button?
On Apr 2, 10:14 pm, "Mudhead" <nowh...@here.comwrote:
What is row suppose to be? It's always 0. How about something like this:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim i, row As Integer
Dim pntcurrent As Point
row = 30
For i = 0 To 9
pntcurrent = New Point((buttonwh + 8), row * i)
Call createbuttons(i, pntcurrent)
Next
For k As Integer = 0 To buttons.GetUpperBound(0)
AddHandler buttons(k).Click, AddressOf button_click
Next
End Sub
"Ron" <pts4...@yahoo.comwrote in message
news:11**********************@d57g2000hsg.googlegr oups.com...
Can anyone help me out? I am trying to add buttons numbered one
through 10 at runtime to a form.
I think they are getting added but they seem to be getting stacked one
on top of each other. so I only see 1, and not the others.
here is what I am doing can anyone tell me what I am doing wrong?
Public Class Form1
Public buttons(9) As Button
Const buttonwh As Integer = 30
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim i, j, row As Integer
Dim pntcurrent As Point
For i = 0 To 9
j = i + 1
pntcurrent = New Point(j + (buttonwh + 8), row)
Call createbuttons(i, pntcurrent)
Next
For k As Integer = 0 To buttons.GetUpperBound(0)
AddHandler buttons(k).Click, AddressOf Button_click
Next
End Sub
Private Sub createbuttons(ByVal i As Integer, _
ByVal pnt As Point)
buttons(i) = New Button
buttons(i).Enabled = True
buttons(i).Visible = True
buttons(i).Text = Convert.ToString(i + 1)
buttons(i).Size = New _
System.Drawing.Size(buttonwh, buttonwh)
buttons(i).Location = pnt
Me.Controls.Add(buttons(i))
End Sub
Private Sub button_click(ByVal sender As System.Object, _
ByVal e As System.EventArgs)
End Sub
End Class- Hide quoted text -
- Show quoted text -
This sounds like a school project. No?
Private Sub button_click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Label1.Text = DirectCast(sender, Button).Text
End Sub
"Ron" <pt*****@yahoo.comwrote in message
news:11**********************@p15g2000hsd.googlegr oups.com...
Ah yes that did it. thank you!
Now what if I wanted to be able to tell what button was being pressed
and know the value of it? Say I want to add a label called
labelbuttons and I want its text property to show 2 if I press
button 2, 3 if i press button three etc?
How would I do this? I just want to make sure that the correct button
referance is there for each button?
On Apr 2, 10:14 pm, "Mudhead" <nowh...@here.comwrote:
>What is row suppose to be? It's always 0. How about something like this:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim i, row As Integer Dim pntcurrent As Point row = 30 For i = 0 To 9 pntcurrent = New Point((buttonwh + 8), row * i) Call createbuttons(i, pntcurrent) Next For k As Integer = 0 To buttons.GetUpperBound(0) AddHandler buttons(k).Click, AddressOf button_click Next End Sub
"Ron" <pts4...@yahoo.comwrote in message
news:11**********************@d57g2000hsg.googleg roups.com...
Can anyone help me out? I am trying to add buttons numbered one
through 10 at runtime to a form.
I think they are getting added but they seem to be getting stacked one
on top of each other. so I only see 1, and not the others.
here is what I am doing can anyone tell me what I am doing wrong?
Public Class Form1
Public buttons(9) As Button
Const buttonwh As Integer = 30
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim i, j, row As Integer
Dim pntcurrent As Point
For i = 0 To 9
j = i + 1
pntcurrent = New Point(j + (buttonwh + 8), row)
Call createbuttons(i, pntcurrent)
Next
For k As Integer = 0 To buttons.GetUpperBound(0)
AddHandler buttons(k).Click, AddressOf Button_click
Next
End Sub
Private Sub createbuttons(ByVal i As Integer, _
ByVal pnt As Point)
buttons(i) = New Button
buttons(i).Enabled = True
buttons(i).Visible = True
buttons(i).Text = Convert.ToString(i + 1)
buttons(i).Size = New _
System.Drawing.Size(buttonwh, buttonwh)
buttons(i).Location = pnt
Me.Controls.Add(buttons(i))
End Sub
Private Sub button_click(ByVal sender As System.Object, _
ByVal e As System.EventArgs)
End Sub
End Class- Hide quoted text -
- Show quoted text -
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Baker |
last post by:
Hi:
I imagine there are hundreds of responses to this question, but i cant find any on the
site using a search.
How do you change the background color of buttons? I know there must be an easy...
|
by: j.mandala |
last post by:
This had got to be something obvious that I am too blind to see!
Funny problem: one of my users has my application linked to a SQL
Server Backend. Front end it Access XP (SP3). The first form...
|
by: DS |
last post by:
Anyone know of any downsides of using Transparent Buttons with Labels
behind them?
Thanks
DS
|
by: Klaus Jensen |
last post by:
Hi!
This has been annoying me for a while now, and I can't get it to work It is
really
driving me nuts!
Basicly this simple webapp created to illustrate my problem, renders five
buttons, and...
|
by: Neil Wallace |
last post by:
Hi there,
I have an application in which a grid of 100 or more buttons are put on a
form in columns of 10.
All the buttons are within a panel.
They are added in runtime, and so they adopt a...
| |
by: barbara_dave |
last post by:
Hi, all,
I have a form which has a picturebox control on the top and several
buttons on the bottom. I want to change the form size smaller at run
time and let all buttons display overlap the...
|
by: Denburt |
last post by:
This code is for a Toggle Button layout on a form, with this code you can set a number of toggle buttons visible and have multiple submenus that will stay hidden when not in use. My main menu is set...
|
by: Ron |
last post by:
I want to create 10 buttons on a form at runtime, the code below is
only creating one button labeled 1. Any idea what I am doing wrong?
Public Class Form1
Public code(10) As String
Public...
|
by: Twayne |
last post by:
Hi,
Newbie to PHP here, no C or other relevant background, so pretty niave
w/r to the nuances etc. but I think this is pretty basic.
XP Pro, SP2+, PHP 4.4.7, XAMPP Local Apache Server...
|
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,...
|
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,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |