Button1_Click() - place my own arguments?

C

Chua Wen Ching

Hi there. this is my codes in vb6:

private Action as integer

private sub button1_Click(index as integer)
Action = Index
End Sub

private sub picture1_mousedown(button as integer, shift as
integer, x as single, y as single)
if Action = 0 then
// draw a square here
end if

if Action = 1 then
// draw a circle
end if

if Action = 2 then
// draw a fillbox
end if
end sub

Yeah.. something like that...

Any help! How will you code that in c#?

In C#, i think it only can button1_click(object sender,
eventargs e)

Thanks.

Regards,
Chua Wen Ching
 
B

Brian Patterson

I would assume that you are using one click event for several buttons in VB
and that each button generates a different "index". Here I would add
ValueButtons to a form (using the source I posted in your message titled
"VB6 Buton.Value") and place this "action/index" value in the Value member
of the button. Then associate each button with the same click event
handler. In the event handler you will have a parameter by the name of
"sender" (type object) which is the button that caused the click event. You
can then typecast this sender to a ValueButton and retrieve the Value
property which will contain your "Action/Index" value.

Of course this is all a best guess since I'm not exactly sure what you are
doing.

Brian Patterson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top