Adding buttons programmatically

G

Guest

Hi

I have a form and I add buttons programmatically in de form_Load function

Anybody know how implements de function button_click if in the designer mode the button doesn't exists

Another question

In a datagrid control is posible programmatically do autosize columns

Another

In a listview is possible that when I select a item doesn't view in blue color

Thank

Silvia
 
M

Mathieu Chavoutier

Silvia said:
Hi,

I have a form and I add buttons programmatically in de form_Load function.

Anybody know how implements de function button_click if in the designer
mode the button doesn't exists?

Inside the function that create the button :
myButton.Click += new EventHandler(iHabeDetectedAClick);

Then, create the function :

private void iHabeDetectedAClick(object sender, EventArgs e)

{

System.Console.WriteLine(The Click Was Detected);

}
 
G

Guest

In Visual Basic I have to do the same?

Thank

----- Mathieu Chavoutier wrote: ----


Silvia said:
mode the button doesn't exists

Inside the function that create the button
myButton.Click += new EventHandler(iHabeDetectedAClick)

Then, create the function

private void iHabeDetectedAClick(object sender, EventArgs e



System.Console.WriteLine(The Click Was Detected)
 
G

Guest

I write in visual basic .net
mybutton.Click = New EventHandler (AddressOf DetectedAClick

private Sub DetectedAClick(ByVal sender as object, ByVal e as EventArgs

I produced an erron in executing mode, its say: An unhandled exception of type "System.InvalidCastException' ocurred i
microsoft.visualbasic.dll. Additional information: Specific cast is not valid

Do you know what is the problema

Thank

----- Mathieu Chavoutier wrote: ----


Silvia said:
mode the button doesn't exists

Inside the function that create the button
myButton.Click += new EventHandler(iHabeDetectedAClick)

Then, create the function

private void iHabeDetectedAClick(object sender, EventArgs e



System.Console.WriteLine(The Click Was Detected)
 
C

Cor Ligthert

Hi Silvia,

Did you know there where dotnet language groups.

By instance
microsoft.public.dotnet.languages.vb
and
microsoft.public.dotnet.languages.csharp

When we have to gues which language and it is wrong is very big.

The questions in this newsgroup are vb:c#:c++:j#

49:49:1,5:0,5

You can tell which language you use here, however I think you can ask these
questions better in a language group there are more people who can answer.

Cor
 
M

Mathieu Chavoutier

Silvia said:
I write in visual basic .net:

Hum, I though it was C#
mybutton.Click = New EventHandler (AddressOf DetectedAClick)

private Sub DetectedAClick(ByVal sender as object, ByVal e as EventArgs)

I produced an erron in executing mode, its say: An unhandled exception of
type "System.InvalidCastException' ocurred in
microsoft.visualbasic.dll. Additional information: Specific cast is not valid.

Do you know what is the problema?

The compiler sais that one of the arguments is not valid, and that it can't
be casted (change type) the one you give in the one it have.

I can't say more, I don't know VB.

Sorry.
 

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