|
Well you can do this either using Property box or even creating the event handler yourself.
this.textBox3.Enter += new System.EventHandler(this.GenericTextBox_Enter);
this.textBox2.Enter += new System.EventHandler(this.GenericTextBox_Enter);
this.textBox1.Enter += new System.EventHandler(this.GenericTextBox_Enter);
private void GenericTextBox_Enter(object sender, EventArgs e)
{
MessageBox.Show(((TextBox)sender).Name);
}
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
You can save characters by simply writing
this.textBox3.Enter += GenericTextBox_Enter;
this.textBox2.Enter += GenericTextBox_Enter;
this.textBox1.Enter += GenericTextBox_Enter;
Easier to read, too.
|
|
|
|
|
caveat. Only from .NET 3.5 IIRC.
|
|
|
|
|
|
Yup, just checked. Introduced in 2.0
|
|
|
|
|
By default, each control has a unique set of event handlers. You can overrirde the hadler to be used on the form's property sheet, look at the events tab.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
What?? That doesnt even make sense!
|
|
|
|
|
What don't you understand:
By default,
The standard easy to use idiot proof click in designer to create an event handler way
each control has a unique set of event handlers.
The event handlers will be named <control>_<event> so there is no reuse.
You can overrirde the hadler to be used
A few spilling mistakes; but who cares.
on the form's property sheet, look at the events tab.
I could have said 'select the control, press F4 - that's the property page, then click the 'lightning strike' to show the event handlers.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Nagy Vilmos wrote: By default, each control has a unique set of event handlers.
The event handlers will be named _ so there is no reuse.
Actually, each control exposes a set of events, not event handlers. And the event handlers aren't generated "by default", you'll have to use the designer to generate them or write them in code.
Your statement would be true only if Visual Studio for some reason generated all event handlers for all events whenever you add a control to a form.
Nagy Vilmos wrote: You can overrirde the hadler to be used
A few spilling mistakes; but who cares.
Typically, you don't override the handler, unless you're talking about overriding OnXXX methods, like OnKeyPress. Instead, you subscribe to event handlers.
Don't get me wrong, I get what you're trying to convey, but you're using the wrong terms, and that might confuse beginners.
|
|
|
|
|
Technically right, however I pretty much stand by my original wording. I'm sure the OP would have got the meaning I was trying to portray.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I think he means using the form designer. Although for doing 20 controls, copy and paste in the code would probably be quicker.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
When you hook up to an event handler, there's the sender object passed in as an argument. This tells you which instance was used to raise the event, so you could just cast this to a TextBox to see which box actually raised the event.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi,
How is it possible to run a vbscript (Stored locally) against a remote machine on the network?
At present I use the following line to execute the vbscript on my machine:
System.Diagnostic.Process.Start("c:\test\vbscriptSample.vbs")
Question:
How do I run this vbscript on a remote machine?
Is there something like:
System.Diagnostic.Process.Start("c:\test\vbscriptSample.vbs, RemoteMachineName")
?
Thanks
|
|
|
|
|
If it is on a networked machine you could do \\machinename\foldername
But the folder has to be shared across the network, also there may be obvious security limitations.
|
|
|
|
|
Hi,
I think what you mean is:
process.start("\\servername\vbscriptfilepath")
?
If this is the case then I believe you kind of mis-understood me.
Let's say you would like to use this vbscript which is on the network to run it against a server on the network.
Using the above code runs a script (depending where it is located) but it gets run on the local machine in which you are called the script from.
Whereas it should run on another machine which I can give the name of.
Hope you follow me.
Thanks
|
|
|
|
|
I feel nice today, next time learn to google.
Process scriptProc = new Process();
scriptProc.StartInfo.FileName = @"cscript";
scriptProc.StartInfo.Arguments ="//B //Nologo c:\test\vbscriptSample.vbs";
scriptProc.Start();
scriptProc.WaitForExit();
scriptProc.Close();
|
|
|
|
|
iges,a usual model in 3D CAD.
I want to show it in my winform.
Thanks.
===========================
http://begtostudy.blogspot.com/
email:begtostudy@gmail.com
MSN:begtostudy@gmail.com
|
|
|
|
|
So buy an Iges viewer.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Personal work.
Poor, no money.
===========================
http://blog.csdn.net/begtostudy
MSN/email:begtostudy@gmail.com
|
|
|
|
|
how to implement iframes in window application using c#
|
|
|
|
|
You have absolutely no idea what you're doing, or you asked this question very strangely. There is no such thing as an iframe in a windows app, why would you need one ?
Christian Graus
Driven to the arms of OSX by Vista.
Please read this[ ^] if you don't like the answer I gave to your question.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
|
|
|
|
|
hi Christian actually i hv a html code now i want the code to show in the windows application as like iframe...is it possible or not or is any way to show the html text in the window app plz help in this regards
thanks in advance
|
|
|
|
|
Use the WebBrowser control.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
hi thanks for ur reply will u tell how can i set the html code to the web browser and can edit the text in the webbrowser and save it
|
|
|
|
|
You could take a look at this[^] code for help.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|