How to Raise/Simluate an Event via Code for a existing Control 
Author Message
 How to Raise/Simluate an Event via Code for a existing Control

Hello

How to Raise/Simluate an Event via Code for a existing Control

I have a situation like this:

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

    End Sub
End Class

With a Button it is posible to Trigger the Click Event
with "Me.Button1.PerformClick()"

Is it posible to call other Events (MouseDown, KeyUp,........ )
for Controls on a From with a trick ?

I mean without creating or inheriting a control by myself ?

Cherrio
Jerry



Fri, 29 Jul 2005 07:02:59 GMT  
 How to Raise/Simluate an Event via Code for a existing Control

Quote:

> Hello

> How to Raise/Simluate an Event via Code for a existing Control

> I have a situation like this:

> Public Class Form1
>     Inherits System.Windows.Forms.Form

>     Private Sub Button1_Click(ByVal sender As System.Object,
> ByVal e As
> System.EventArgs) Handles Button1.Click

>     End Sub
> End Class

> With a Button it is posible to Trigger the Click Event
> with "Me.Button1.PerformClick()"

> Is it posible to call other Events (MouseDown, KeyUp,........ )
> for Controls on a From with a trick ?

> I mean without creating or inheriting a control by myself ?

Seperate event procedures from action procedures. In the event procedures,
call the action procedures (that do the actual job). Now you can call the
action procedures instead of the event procedures wherever you want without
simulating a mouse click that hasn't been performed.

Armin



Fri, 29 Jul 2005 16:35:25 GMT  
 How to Raise/Simluate an Event via Code for a existing Control
Thanx for the Hint.

My Problem is difficult.

I have Access to a Button but not to the Button_Click Event Routine of the
Form because the
Button_Click Event Routine is private and the Button Public.

I am shure it is hard to understand what I want
but I hav no Access to the Code in which the Button is declared.

I only have Access to the Button Object !!

I searching for a way that I can Raise a Button_Click Event
only with having the Button Object. (No Access to the Routine !!)

Anyway thanx



Quote:

> > Hello

> > How to Raise/Simluate an Event via Code for a existing Control

> > I have a situation like this:

> > Public Class Form1
> >     Inherits System.Windows.Forms.Form

> >     Private Sub Button1_Click(ByVal sender As System.Object,
> > ByVal e As
> > System.EventArgs) Handles Button1.Click

> >     End Sub
> > End Class

> > With a Button it is posible to Trigger the Click Event
> > with "Me.Button1.PerformClick()"

> > Is it posible to call other Events (MouseDown, KeyUp,........ )
> > for Controls on a From with a trick ?

> > I mean without creating or inheriting a control by myself ?

> Seperate event procedures from action procedures. In the event procedures,
> call the action procedures (that do the actual job). Now you can call the
> action procedures instead of the event procedures wherever you want
without
> simulating a mouse click that hasn't been performed.

> Armin



Sat, 30 Jul 2005 02:58:46 GMT  
 How to Raise/Simluate an Event via Code for a existing Control

Quote:
> I have Access to a Button but not to the Button_Click Event
> Routine of the Form because the
> Button_Click Event Routine is private and the Button Public.

> I am shure it is hard to understand what I want
> but I hav no Access to the Code in which the Button is declared.

> I only have Access to the Button Object !!

> I searching for a way that I can Raise a Button_Click Event
> only with having the Button Object. (No Access to the Routine !!)

But you have a reference to the Form? Something like
TheForm.Button1.PerformClick?

For example, if the Button is a "Save"-Button:

In the Form:
    private sub button_click(bla)
        Save
    end sub

    public Sub Save
        'Save here
    end sub

Now you can call TheForm.Save from outside the form.

Does this help?

Armin



Sat, 30 Jul 2005 03:11:37 GMT  
 How to Raise/Simluate an Event via Code for a existing Control
Hey Ho Armin thanx for help.

I understand what you mean but that is no solution for my Problem.

I have no influence of the Code...... I can not write something in the Form.

The Code is written by someone else and I can only Access the DLL.

And that is the Problem.......

I want to Raise the Event only by having the Button Object..........

Thanx anyway and Cherrio



Quote:

> > I have Access to a Button but not to the Button_Click Event
> > Routine of the Form because the
> > Button_Click Event Routine is private and the Button Public.

> > I am shure it is hard to understand what I want
> > but I hav no Access to the Code in which the Button is declared.

> > I only have Access to the Button Object !!

> > I searching for a way that I can Raise a Button_Click Event
> > only with having the Button Object. (No Access to the Routine !!)

> But you have a reference to the Form? Something like
> TheForm.Button1.PerformClick?

> For example, if the Button is a "Save"-Button:

> In the Form:
>     private sub button_click(bla)
>         Save
>     end sub

>     public Sub Save
>         'Save here
>     end sub

> Now you can call TheForm.Save from outside the form.

> Does this help?

> Armin



Sat, 30 Jul 2005 04:08:41 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. raising an event from an activeX control on a htm page in a webbrower control

2. Raising Custom Active X Controls Events when using Data Repeater Control

3. raising an event from an activeX control on a htm page in a webbrower control

4. Raise an Event with code

5. How to determine via code that a table exists

6. Detecting which control raised an event

7. HELP!!! raising events from a custom control

8. Help Raising Events in User Controls

9. Q: Raising events in webbrowser control

10. Raising Custom Events in an OCX Control

11. Event from dynamically created control doesn't raise

12. raise event without timer control

 

 
Powered by phpBB® Forum Software