Buttons...

iitk

Newcomer
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 can't 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 I'm afraid...

The .NET framework doesn't 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.
Visual Basic:
DirectCast(sender, Button).Text = "some text"
 
Back
Top