473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Raise event problem


I have a vb.net 2005 app I am creating, I also have a separate user control
that I have created separate from the app.

On the control I have:

Namespace HLMultiSelect.Forms.Controls
Public Class HLMultiSelect

Inherits System.Windows.Forms.Control

Public Event ReportMouseStatus(ByVal bStatus As Boolean)

Private Sub HLSelectButton_MouseEnter(ByVal sender As Object, ByVal
e As System.EventArgs) Handles Me.MouseEnter
mMouseHover = True
Invalidate()

RaiseEvent ReportMouseStatus(True)

End Sub

Private Sub HLSelectButton_MouseLeave(ByVal sender As Object, ByVal
e As System.EventArgs) Handles Me.MouseLeave

mMouseHover = False
Invalidate()

RaiseEvent ReportMouseStatus(False)
End Sub

End Class

End Namespace

On the app that I am creating I have:

Imports HLMultiSelect.Forms.Controls
Public Class Form1

Public WithEvents sMouse As New HLMultiSelect
Private Sub sMouse_ReportMouseStatus(ByVal bStatus As Boolean) Handles
sMouse.ReportMouseStatus

MsgBox("hello")

End Sub

Id does not fire, am I missing something?

The only thing that calls the event is when the user puts the mouse over the
control.


Sep 23 '08 #1
3 2231
Andrew wrote:
>
The only thing that calls the event is when the user puts the mouse
over the control.
Which never happens, because the control is not on a form, where the user to put
their mouse over it.

You could either put an instance of the control on Form1, and then handle that
instance's ReportMouseStatus event, or you can do as you have done, and then add
sMouse to the form's controls, using Me.Controls.Add. You will probably need to
give it a position and size, and make sure it is visible, if you go that way.
Sep 24 '08 #2
It is a control on a form, but I was able to solve the problem, I did not
make the Public Event ReportMouseStatus(ByVal bStatus As Boolean)
A shared event.

Thanks for the help..


"Steve Gerrard" wrote:
Andrew wrote:

The only thing that calls the event is when the user puts the mouse
over the control.

Which never happens, because the control is not on a form, where the user to put
their mouse over it.

You could either put an instance of the control on Form1, and then handle that
instance's ReportMouseStatus event, or you can do as you have done, and then add
sMouse to the form's controls, using Me.Controls.Add. You will probably need to
give it a position and size, and make sure it is visible, if you go that way.
Sep 24 '08 #3
Andrew wrote:
It is a control on a form, but I was able to solve the problem, I did
not make the Public Event ReportMouseStatus(ByVal bStatus As Boolean)
A shared event.
That suggests to me that the control you are getting the event from (sMouse, the
one you created with New), is not the same as the one that actually picked up
the mouse (the one you have on the form).

If that is okay with you, it is fine, but if there is already a control on the
form, there is no need to create another one with New; just capture the event
from the one on the control.
Sep 24 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dan Cimpoiesu | last post by:
I have a remoting object, derived from MarshalByRefComponent, that I instantiate on the client side, with Activator.GetObject. Can I receive events fired on the server, on the client? How?
5
by: Mark Overstreet | last post by:
I am writing an app that needs to contain an object model that allows it to be controlled similiar to something like Word. However, I am writing this in C# and all managed code. I know that I can...
0
by: Tonix | last post by:
This problem was originated by Thanh Nguyen. Your help is appreciated. Thanks. The original text is: Hi everyone, I'm encountering a very weird problem, I have spent the last 3 days trying to...
4
by: Charles Law | last post by:
Suppose a worker thread needs to signal to the main thread that an event has occurred. Ordinarily, any event raised by the worker thread will be on its own thread. How can the worker thread...
12
by: Vittorio Pavesi | last post by:
Hello, is it possible to manually raise the event Elapsed of the timer object ? Vittorio
4
by: Jeremy | last post by:
I have a combobox with a SelectionChangeCommitted event handler, and am having a problem raising this event. For example, raiseEvent mycombobox.SelectionChangeCommitted gives me an error...
2
by: Pietro | last post by:
Hello, somebody know how to raise an event from a nested class? I have two classes, the class1 with 1 events, and a nested class (class2) inside the class1. So... How can I raise class1 events...
1
by: Anonieko | last post by:
I know Visual Studio lacked support on easily writing code to raise events from a ascx user control ( because you have to hand write them)....
3
by: =?Utf-8?B?Ulc=?= | last post by:
I constructed a new Class with some private members. I would like an event to be raised on the moment the value of one of those private members is changed. How do I define an event for that...
5
by: Mike | last post by:
Hi group; Let say I have an object called Account, that raises an event called AccountLow with its owns EventArgs, and when this event gets raised, I will like to raise another custom...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.