Kevin / Glenn,
Thank you for the replies. I posted this question on another user
group and got slightly ripped by one of the posters. They wanted to
know why I was trying to manaully fire an Event that I didn't write
the Handler. Other then it seemed like a good idea at the time, I
could come up with an answer. But based on their response, fine ok,
I'll write my own Event, handel it, and fire it when I needed too.
Some developers get soooo touching that way :-)
-B
On Aug 14, 5:47 pm, Glenn <[EMAIL PROTECTED]> wrote:
> What you have will work, but there is an easier way of doing it. You can
> simply loop through all the controls in the form, set the focus to the
> control and call the parent control's Validate method. This will cause the
> control's OnValidating handler to be called. I did this method to allow me
> to utilize a common "Validate" function that I could pass in the form to
> validate and have all controls validated with one function call.
>
> ...Glenn
>
>
>
>
>
> On Wed, Aug 13, 2008 at 1:54 AM, BJ <[EMAIL PROTECTED]> wrote:
>
> > Most Events take two parameters. An object and a parameter
> > (eventargs) list. Below is an example of something I am trying to do
> > in a much larger application. It works, but so does a screw driver on
> > most car ignitions. Is this the correct way; am I asking for trouble;
> > or is there a cleaner way?
> > TIA
>
> > namespace WindowsApplication1
> > {
> > public partial class Form1 : Form
> > {
> > public Form1()
> > {
> > InitializeComponent();
> > }
>
> > private void textBox1_Validating(object sender,
> > CancelEventArgs e)
> > {
> > if (textBox1.Text.Length == 0)
> > {
> > e.Cancel = true;
> > textBox1.Select(0, textBox1.Text.Length);
>
> > // Set the ErrorProvider error with the text to
> > display.
> > this.errorProvider1.SetError(textBox1, "ERROR");
>
> > }
> > else
> > {
> > e.Cancel = false;
> > }
> > }
>
> > private void Form1_Shown(object sender, EventArgs e)
> > {
> > object myOBJ = new object();
> > CancelEventArgs k = new CancelEventArgs();
> > textBox1_Validating(this.textBox1, k);
> > }
> > }
> > }
>
> --
> ------------------------------------------------------http://onefryshort.org/http://blog.onefryshort.org/
> ------------------------------------------------------- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
<p><a href="http://feeds.feedburner.com/DotNetDevelopment"><img
src="http://feeds.feedburner.com/~fc/DotNetDevelopment?bg=99CCFF&fg=444444&anim=1"
height="26" width="88" style="border:0" alt="" /></a></p>
-~----------~----~----~----~------~----~------~--~---