simmulate real rowEnter on DataGridView object.

M

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 :)
 
A

Armin Zingler

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.
 
M

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 :)
 
A

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.
 
C

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)
 
C

Cor Ligthert[MVP]

Armin,

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

But a very good analogy.

Cor

..
 
A

Armin Zingler

Am 25.04.2010 11:20, schrieb Cor Ligthert[MVP]:
Armin,

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

But a very good analogy.

Cor

..

:) 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top