Home All Groups Group Topic Archive Search About

simmulate real rowEnter on DataGridView object.

Author
24 Apr 2010 8:04 AM
Mr. X.
Hello.
I want to do by force : RowEnter event of DataGridViewObject.

I made a function on my code :
    Public Sub ReEnter()
        Invoke(New EventHandler(AddressOf dg_RowEnter))
    End Sub

Where dg_RowEnter is the event :
Private Sub dg_RowEnter(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles Me.RowEnter


Why I don't reach the sub : dg_RowEnter, as I have described in the code
above?

Thanks :)

Author
24 Apr 2010 10:59 AM
Armin Zingler
Am 24.04.2010 10:04, schrieb Mr. X.:
Show quoteHide quote
> Hello.
> I want to do by force : RowEnter event of DataGridViewObject.
>
> I made a function on my code :
>     Public Sub ReEnter()
>         Invoke(New EventHandler(AddressOf dg_RowEnter))
>     End Sub
>
> Where dg_RowEnter is the event :
> Private Sub dg_RowEnter(ByVal sender As System.Object, ByVal e As
> System.Windows.Forms.DataGridViewCellEventArgs) Handles Me.RowEnter
>
>
> Why I don't reach the sub : dg_RowEnter, as I have described in the code
> above?

Why do you use Invoke? It's used for cross-thread calls.
And why call an event handler? Which event occured?

If you want to set the currenct cell, you have to set a property or
call a method of the control.

--
Armin
Author
24 Apr 2010 12:02 PM
Mr. X.
I want to force RowEnter event (Which exists on DataGridView).
Like forcing clicking on button.
On some languages I assume it is called fireEvent).
I don't want to set the current cell, just do RowEnter, for instance.

Thanks :)

Show quoteHide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:OULt2254KHA.980@TK2MSFTNGP04.phx.gbl...
> Am 24.04.2010 10:04, schrieb Mr. X.:
>> Hello.
>> I want to do by force : RowEnter event of DataGridViewObject.
>>
>> I made a function on my code :
>>     Public Sub ReEnter()
>>         Invoke(New EventHandler(AddressOf dg_RowEnter))
>>     End Sub
>>
>> Where dg_RowEnter is the event :
>> Private Sub dg_RowEnter(ByVal sender As System.Object, ByVal e As
>> System.Windows.Forms.DataGridViewCellEventArgs) Handles Me.RowEnter
>>
>>
>> Why I don't reach the sub : dg_RowEnter, as I have described in the code
>> above?
>
> Why do you use Invoke? It's used for cross-thread calls.
> And why call an event handler? Which event occured?
>
> If you want to set the currenct cell, you have to set a property or
> call a method of the control.
>
> --
> Armin
Author
24 Apr 2010 2:00 PM
Armin Zingler
Am 24.04.2010 14:02, schrieb Mr. X.:
> I want to force RowEnter event (Which exists on DataGridView).
> Like forcing clicking on button.
> On some languages I assume it is called fireEvent).
> I don't want to set the current cell, just do RowEnter, for instance.

Whenever the sun shines, your solar cells work and the generated
power switches a lever. If it's dark, you have to switch the lever
manually instead of trying to make the sun shine.


--
Armin
Author
25 Apr 2010 9:07 AM
Cor Ligthert[MVP]
ROFL,

With what Armin shows that he has already answered your question in the
previous message.

Calling the Row change method

MyRowChangeMethod(nothing,nothing)

If you use the sender and the eventsarguments in your invoked method, then
you have first to set that sender and eventsargs

MyRowChangeMethod(myCreatedSender,MyCreatedEeventsArgument)



Show quoteHide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:eEDDdb74KHA.5848@TK2MSFTNGP06.phx.gbl...
> Am 24.04.2010 14:02, schrieb Mr. X.:
>> I want to force RowEnter event (Which exists on DataGridView).
>> Like forcing clicking on button.
>> On some languages I assume it is called fireEvent).
>> I don't want to set the current cell, just do RowEnter, for instance.
>
> Whenever the sun shines, your solar cells work and the generated
> power switches a lever. If it's dark, you have to switch the lever
> manually instead of trying to make the sun shine.
>
>
> --
> Armin
>
Author
25 Apr 2010 9:20 AM
Cor Ligthert[MVP]
Armin,

In fact, very much my style, I had not expected this from you.

But a very good analogy.

Cor

..
Show quoteHide quote
>
> Whenever the sun shines, your solar cells work and the generated
> power switches a lever. If it's dark, you have to switch the lever
> manually instead of trying to make the sun shine.
Author
25 Apr 2010 10:19 AM
Armin Zingler
Am 25.04.2010 11:20, schrieb Cor Ligthert[MVP]:
Show quoteHide quote
> Armin,
>
> In fact, very much my style, I had not expected this from you.
>
> But a very good analogy.
>
> Cor
>
> ..
>>
>> Whenever the sun shines, your solar cells work and the generated
>> power switches a lever. If it's dark, you have to switch the lever
>> manually instead of trying to make the sun shine.


:-) Well, but you're putting a torch on the solar cells to "produce" energy,
whereas I'm pressing the lever myself. So we don't agree.

In other words: Never call an event handler manually. No event occured.
Instead, start the same thing in the event handler and also in the code
where you want to start it.

And in code words: (also for Mr. Eggs)

       sub MyRowChangeMethod(sender, args)

             DoIt  'Here's where you want to do it

       End Sub


       sub YetAnotherMethod

            yadayada
            DoIt    'and here you wanna do it also
            yadayada

       end sub


       sub DoIt

           debug.print "about to do it..."
           sleep a long time
           debug.print "dunnit!"

       end sub


--
Armin