468,527 Members | 2,110 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,527 developers. It's quick & easy.

button click event

Hi, All,

I create button in the code ( Dim Button as new Button), not using button
web component (means not drap button and drop it ont he webform), after that
I try to use button_click event, it is not work, anyone can tell how to use
button click event ?

Thanks in advance,
Martin
May 24 '07 #1
7 6423
On May 24, 12:53 pm, martin1 <mart...@discussions.microsoft.com>
wrote:
Hi, All,

I create button in the code ( Dim Button as new Button), not using button
web component (means not drap button and drop it ont he webform), after that
I try to use button_click event, it is not work, anyone can tell how to use
button click event ?

Thanks in advance,
Martin
AddHandler

Thanks,

Seth Rowe

May 24 '07 #2
Hi, Seth Rowe,

could you give sample on how to use addhandler,

Thanks,
martin

"rowe_newsgroups" wrote:
On May 24, 12:53 pm, martin1 <mart...@discussions.microsoft.com>
wrote:
Hi, All,

I create button in the code ( Dim Button as new Button), not using button
web component (means not drap button and drop it ont he webform), after that
I try to use button_click event, it is not work, anyone can tell how to use
button click event ?

Thanks in advance,
Martin

AddHandler

Thanks,

Seth Rowe

May 24 '07 #3
On May 24, 1:36 pm, martin1 <mart...@discussions.microsoft.comwrote:
Hi, Seth Rowe,

could you give sample on how to use addhandler,

Thanks,
martin

"rowe_newsgroups" wrote:
On May 24, 12:53 pm, martin1 <mart...@discussions.microsoft.com>
wrote:
Hi, All,
I create button in the code ( Dim Button as new Button), not using button
web component (means not drap button and drop it ont he webform), after that
I try to use button_click event, it is not work, anyone can tell how to use
button click event ?
Thanks in advance,
Martin
AddHandler
Thanks,
Seth Rowe
Private Sub Form_Load(sender As Object, e As EventArgs)
Dim btn as new Button()
AddHandler btn.Click, AddressOf Button_Click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
' Do something useful
End Sub

Thanks,

Seth Rowe

May 24 '07 #4
Thank you! Seth Rowe

What I want to do is let user click each button to pop up message which is
related to StatusDesc field of Sysstat Table, the message is dynamic. The
problem (look at code below) is StatusDesc message is overwritten by next
loop, so how to keep statusDesc message for each button?

The Code like:
---------------------------------------------------
Pub Class _Default
Dim StatusDesc As String

Private Sub Form_Load(sender As Object, e As EventArgs)

For Each row In dtSysstat.Rows ' loop each record of sysstat table
Dim button As New Button ' create button for each row

btnText = Trim(row.Item("ButtonName")) ' get ButtonName
from table
StatusDesc = Trim(row.Item("StatusDesc").ToString) 'get
StatusDesc

button.Text = btnText
panel.Controls.Add(button)

' add click event to button
AddHandler button.Click, AddressOf Button_click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
MsgBox(StatusDesc)
End Sub

End Class
------------------------------------------------
Thank you again,
Martin
"rowe_newsgroups" wrote:
On May 24, 1:36 pm, martin1 <mart...@discussions.microsoft.comwrote:
Hi, Seth Rowe,

could you give sample on how to use addhandler,

Thanks,
martin

"rowe_newsgroups" wrote:
On May 24, 12:53 pm, martin1 <mart...@discussions.microsoft.com>
wrote:
Hi, All,
I create button in the code ( Dim Button as new Button), not using button
web component (means not drap button and drop it ont he webform), after that
I try to use button_click event, it is not work, anyone can tell how to use
button click event ?
Thanks in advance,
Martin
AddHandler
Thanks,
Seth Rowe

Private Sub Form_Load(sender As Object, e As EventArgs)
Dim btn as new Button()
AddHandler btn.Click, AddressOf Button_Click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
' Do something useful
End Sub

Thanks,

Seth Rowe

May 24 '07 #5

"martin1" <ma*****@discussions.microsoft.comwrote in message
news:09**********************************@microsof t.com...
Thank you! Seth Rowe

What I want to do is let user click each button to pop up message which is
related to StatusDesc field of Sysstat Table, the message is dynamic. The
problem (look at code below) is StatusDesc message is overwritten by next
loop, so how to keep statusDesc message for each button?

The Code like:
---------------------------------------------------
Pub Class _Default
Dim StatusDesc As String

Private Sub Form_Load(sender As Object, e As EventArgs)

For Each row In dtSysstat.Rows ' loop each record of sysstat table
Dim button As New Button ' create button for each row

btnText = Trim(row.Item("ButtonName")) ' get ButtonName
from table
StatusDesc = Trim(row.Item("StatusDesc").ToString) 'get
StatusDesc

button.Text = btnText
panel.Controls.Add(button)

' add click event to button
AddHandler button.Click, AddressOf Button_click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
MsgBox(StatusDesc)
End Sub

End Class
------------------------------------------------
Thank you again,
Martin
"rowe_newsgroups" wrote:
>On May 24, 1:36 pm, martin1 <mart...@discussions.microsoft.comwrote:
Hi, Seth Rowe,

could you give sample on how to use addhandler,

Thanks,
martin

"rowe_newsgroups" wrote:
On May 24, 12:53 pm, martin1 <mart...@discussions.microsoft.com>
wrote:
Hi, All,

I create button in the code ( Dim Button as new Button), not using
button
web component (means not drap button and drop it ont he webform),
after that
I try to use button_click event, it is not work, anyone can tell
how to use
button click event ?

Thanks in advance,
Martin

AddHandler

Thanks,

Seth Rowe

Private Sub Form_Load(sender As Object, e As EventArgs)
Dim btn as new Button()
AddHandler btn.Click, AddressOf Button_Click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
' Do something useful
End Sub

Thanks,

Seth Rowe

When you create the button, set btn.tag = StatusDesc. Then when you handle
the click event you can cast the sender to a button and retrieve the tag as
the description.

Hope this helps

Lloyd Sheen

May 24 '07 #6
Hi, Lloyd Sheen,

it works, Thank you so much,

Martin

"Lloyd Sheen" wrote:
>
"martin1" <ma*****@discussions.microsoft.comwrote in message
news:09**********************************@microsof t.com...
Thank you! Seth Rowe

What I want to do is let user click each button to pop up message which is
related to StatusDesc field of Sysstat Table, the message is dynamic. The
problem (look at code below) is StatusDesc message is overwritten by next
loop, so how to keep statusDesc message for each button?

The Code like:
---------------------------------------------------
Pub Class _Default
Dim StatusDesc As String

Private Sub Form_Load(sender As Object, e As EventArgs)

For Each row In dtSysstat.Rows ' loop each record of sysstat table
Dim button As New Button ' create button for each row

btnText = Trim(row.Item("ButtonName")) ' get ButtonName
from table
StatusDesc = Trim(row.Item("StatusDesc").ToString) 'get
StatusDesc

button.Text = btnText
panel.Controls.Add(button)

' add click event to button
AddHandler button.Click, AddressOf Button_click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
MsgBox(StatusDesc)
End Sub

End Class
------------------------------------------------
Thank you again,
Martin
"rowe_newsgroups" wrote:
On May 24, 1:36 pm, martin1 <mart...@discussions.microsoft.comwrote:
Hi, Seth Rowe,

could you give sample on how to use addhandler,

Thanks,
martin

"rowe_newsgroups" wrote:
On May 24, 12:53 pm, martin1 <mart...@discussions.microsoft.com>
wrote:
Hi, All,

I create button in the code ( Dim Button as new Button), not using
button
web component (means not drap button and drop it ont he webform),
after that
I try to use button_click event, it is not work, anyone can tell
how to use
button click event ?

Thanks in advance,
Martin

AddHandler

Thanks,

Seth Rowe

Private Sub Form_Load(sender As Object, e As EventArgs)
Dim btn as new Button()
AddHandler btn.Click, AddressOf Button_Click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
' Do something useful
End Sub

Thanks,

Seth Rowe


When you create the button, set btn.tag = StatusDesc. Then when you handle
the click event you can cast the sender to a button and retrieve the tag as
the description.

Hope this helps

Lloyd Sheen
May 25 '07 #7
Hi,

Is there any way we can use mouse-over-button event instead button-click
event? What i want to do is instead let user click button to pop up message i
let user put mouse over button and then auto-pop up message?

Thanks,
Martin

"Lloyd Sheen" wrote:
>
"martin1" <ma*****@discussions.microsoft.comwrote in message
news:09**********************************@microsof t.com...
Thank you! Seth Rowe

What I want to do is let user click each button to pop up message which is
related to StatusDesc field of Sysstat Table, the message is dynamic. The
problem (look at code below) is StatusDesc message is overwritten by next
loop, so how to keep statusDesc message for each button?

The Code like:
---------------------------------------------------
Pub Class _Default
Dim StatusDesc As String

Private Sub Form_Load(sender As Object, e As EventArgs)

For Each row In dtSysstat.Rows ' loop each record of sysstat table
Dim button As New Button ' create button for each row

btnText = Trim(row.Item("ButtonName")) ' get ButtonName
from table
StatusDesc = Trim(row.Item("StatusDesc").ToString) 'get
StatusDesc

button.Text = btnText
panel.Controls.Add(button)

' add click event to button
AddHandler button.Click, AddressOf Button_click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
MsgBox(StatusDesc)
End Sub

End Class
------------------------------------------------
Thank you again,
Martin
"rowe_newsgroups" wrote:
On May 24, 1:36 pm, martin1 <mart...@discussions.microsoft.comwrote:
Hi, Seth Rowe,

could you give sample on how to use addhandler,

Thanks,
martin

"rowe_newsgroups" wrote:
On May 24, 12:53 pm, martin1 <mart...@discussions.microsoft.com>
wrote:
Hi, All,

I create button in the code ( Dim Button as new Button), not using
button
web component (means not drap button and drop it ont he webform),
after that
I try to use button_click event, it is not work, anyone can tell
how to use
button click event ?

Thanks in advance,
Martin

AddHandler

Thanks,

Seth Rowe

Private Sub Form_Load(sender As Object, e As EventArgs)
Dim btn as new Button()
AddHandler btn.Click, AddressOf Button_Click
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
' Do something useful
End Sub

Thanks,

Seth Rowe


When you create the button, set btn.tag = StatusDesc. Then when you handle
the click event you can cast the sender to a button and retrieve the tag as
the description.

Hope this helps

Lloyd Sheen
May 30 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by yfng | last post: by
2 posts views Thread by Liqun Xu | last post: by
6 posts views Thread by Michael Johnson Jr. | last post: by
4 posts views Thread by Mark Lingen | last post: by
11 posts views Thread by CW | last post: by
3 posts views Thread by Imran Aziz | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.