Buttons...

iitk

New member
Joined
Nov 25, 2003
Messages
3
I am writing a handler for a button click event in the compact .NET framework.

You have the two arguments object and eventarguments.

What I need is the caption of the button... but I cant work out how to get it :(

Any clues gratefully accepted!!

Dom
 
string text = Button1.Text; C#
Dim text as string = Button1.Text VB

is that what you are looking for?
 
Not quite as easy as that Im afraid...

The .NET framework doesnt allow late binding so I cannot pickup information such as eventsender.text

There must be some way of getting the caption on the button inside its own click event!! Even in the cut down compact framework!!

:eek:
 
You have to cast the sender object that is passed in to a button type. Then after casting you can access the properties of the button. To cast, use the DirectCast keyword.
Code:
DirectCast(sender, Button).Text = "some text"
 
Back
Top