Click here to Skip to main content
15,860,972 members
Home / Discussions / C#
   

C#

 
QuestionHow can I software-trigger WndProc(ref Message m) to execute? Pin
arnold_w16-Sep-19 0:40
arnold_w16-Sep-19 0:40 
AnswerRe: How can I software-trigger WndProc(ref Message m) to execute? Pin
Richard MacCutchan16-Sep-19 1:26
mveRichard MacCutchan16-Sep-19 1:26 
GeneralRe: How can I software-trigger WndProc(ref Message m) to execute? Pin
arnold_w16-Sep-19 22:00
arnold_w16-Sep-19 22:00 
GeneralRe: How can I software-trigger WndProc(ref Message m) to execute? Pin
Richard MacCutchan16-Sep-19 22:45
mveRichard MacCutchan16-Sep-19 22:45 
GeneralRe: How can I software-trigger WndProc(ref Message m) to execute? Pin
BillWoodruff17-Sep-19 17:49
professionalBillWoodruff17-Sep-19 17:49 
AnswerRe: How can I software-trigger WndProc(ref Message m) to execute? Pin
BillWoodruff17-Sep-19 17:57
professionalBillWoodruff17-Sep-19 17:57 
QuestionUsing buttons on a form. Pin
Brian_TheLion15-Sep-19 17:48
Brian_TheLion15-Sep-19 17:48 
AnswerRe: Using buttons on a form. Pin
OriginalGriff15-Sep-19 20:43
mveOriginalGriff15-Sep-19 20:43 
Brian_TheLion wrote:
A lot of books deal with the console side of c# more than the form side.

I'd disagree with that, quite strongly: most "beginner" books start with the Console, because it's a lot easier to get your head round - but quickly move away to WinForms or WPF because that's what gets used in the real world. Certainly, all the Addison Wesley, Wrox, and Microsoft Press books that I've read do!

But it's pretty easy - it all works via Events. When you click the button, it generates an Event called "Click" which the Form (or another container like a UserControl perhaps) handles.

Open your form in the designer.
Double click the button. That will add a Click event handler to the form and open the code window to let you type code into the handler method.
Type your code:
C#
MessageBox.Show("The Yes button was clicked", "My form event handler", MessageBoxButtons.OK, MessageBoxIcon.Information);
And run your app.
Click the button, and the message will appear!

You code will look like this:
C#
private void YesButton_Click(object sender, EventArgs e)
    {
    MessageBox.Show("The Yes button was clicked", "My form event handler", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
Because the system will add the handler method framework for you:
private           So that it is only usable inside the form.
void              Because it doesn't return a value
YesButton_Click   Name of the handler method: YesButton Click event
object sender     "sender" is object that raised the event (useful if several buttons share the same handler)
EventArgs e       Provides extra information on the event if you need it.

Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

AnswerRe: Using buttons on a form. Pin
GenJerDan15-Sep-19 20:55
GenJerDan15-Sep-19 20:55 
GeneralRe: Using buttons on a form. Pin
BillWoodruff16-Sep-19 4:32
professionalBillWoodruff16-Sep-19 4:32 
AnswerRe: Using buttons on a form. Pin
BillWoodruff16-Sep-19 4:30
professionalBillWoodruff16-Sep-19 4:30 
AnswerRe: Using buttons on a form. Pin
Brian_TheLion16-Sep-19 16:20
Brian_TheLion16-Sep-19 16:20 
GeneralRe: Using buttons on a form. Pin
BillWoodruff16-Sep-19 16:36
professionalBillWoodruff16-Sep-19 16:36 
GeneralRe: Using buttons on a form. Pin
Brian_TheLion16-Sep-19 20:40
Brian_TheLion16-Sep-19 20:40 
AnswerRe: Using buttons on a form. Pin
BillWoodruff16-Sep-19 22:49
professionalBillWoodruff16-Sep-19 22:49 
GeneralRe: Using buttons on a form. Pin
Brian_TheLion17-Sep-19 20:03
Brian_TheLion17-Sep-19 20:03 
QuestionFile format not proper for excel mail attachment in c# Pin
Member 1225501213-Sep-19 8:33
Member 1225501213-Sep-19 8:33 
AnswerRe: File format not proper for excel mail attachment in c# Pin
MadMyche13-Sep-19 11:59
professionalMadMyche13-Sep-19 11:59 
QuestionHow to get the Websocketdata from server? Pin
Member 1457084312-Sep-19 6:46
Member 1457084312-Sep-19 6:46 
AnswerRe: How to get the Websocketdata from server? Pin
Richard MacCutchan12-Sep-19 6:49
mveRichard MacCutchan12-Sep-19 6:49 
GeneralRe: How to get the Websocketdata from server? Pin
Member 1457084312-Sep-19 7:14
Member 1457084312-Sep-19 7:14 
GeneralRe: How to get the Websocketdata from server? Pin
Richard MacCutchan12-Sep-19 11:15
mveRichard MacCutchan12-Sep-19 11:15 
AnswerRe: How to get the Websocketdata from server? Pin
ZurdoDev12-Sep-19 9:48
professionalZurdoDev12-Sep-19 9:48 
AnswerRe: How to get the Websocketdata from server? Pin
Gerry Schmitz12-Sep-19 20:36
mveGerry Schmitz12-Sep-19 20:36 
AnswerRe: How to get the Websocketdata from server? Pin
OriginalGriff13-Sep-19 0:25
mveOriginalGriff13-Sep-19 0:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.