i have a window form that has usename and a password but i cant get my 2 buttons submit and cancel to work dose anyone know where i could look to learn more on how to make my buttons work ty all

Recommended Answers

All 5 Replies

You need to have a DialogResult item such as

DialogResult dr = newForm.ShowDialog();
            if (dr == DialogResult.OK)
            {//do something}

Then in your prompt you need to set the buttons to have the correct dialogue result values. You can either set these by code or by the property panel.

Hope that helps.

usually double clicking the buttons in the ide form design mode will automatically generate code for button events :)

usually double clicking the buttons in the ide form design mode will automatically generate code for button events :)

But that will be in the form CONTAINING the button rather than the form that called the dialogue box.

sorry all he asked was how to make a button to work and the window part was really irrelavant, so how can you say my answer is wrong :). and you forgot to mention you actually have to set how the buttons will return by changing the dialog results property of the button. '

Oops my bad. Answering what I thought was there not what is actually there.

Ignore my reply.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.