G
Guest
Does anyone know of a way to call events directly in c#, in the way you can
use the RaiseEvent command in VB.net?
I have a form (a custom soft input panel), which contains a member variable
of type TextBox. When you enter a text box on any main application form, the
text box passes itself to the SIP form, and shows the SIP form.
The SIP form then uses an event handler from it's own buttons (the input
keys) to append or delete text from the textbox (ie. you click the '7' button
on the SIP form, and '7' is appended to the text box on the application
form). This works in the same way as the pocket pc/win ce SIP. However, i
also need to fire events of the text boxes passed in, so that the validation
can be carried out. For example, i place the validation in the Key Up event
handler of the text box on the main application form, and then within the SIP
form, i can fire the Key Up event of the text box.
However, you cannot do this in C#. You can call an event of a class
directly only from within the class itself.
Therefore, i then tried extending the TextBox class into TextBoxExt, and in
TextBoxExt added a method FireKeyUp. I can then call the FireKeyUp method of
my extended class which calls the KeyUp event of its base class.
This is OK in theory (and works perfectly in the full framework), but when I
change the definition in my main form's text box from
System.Windows.Forms.TextBox to TextBoxExt - it disappears from the designer.
I think this is because of the compact framework's lack of support for
designing user controls, etc.
So if i was in VB.net, i could use RaiseEvent, and if I was in the full
framework in c#, i could use a user control/inherited class.
Any suggestions welcome!
Thanks.
use the RaiseEvent command in VB.net?
I have a form (a custom soft input panel), which contains a member variable
of type TextBox. When you enter a text box on any main application form, the
text box passes itself to the SIP form, and shows the SIP form.
The SIP form then uses an event handler from it's own buttons (the input
keys) to append or delete text from the textbox (ie. you click the '7' button
on the SIP form, and '7' is appended to the text box on the application
form). This works in the same way as the pocket pc/win ce SIP. However, i
also need to fire events of the text boxes passed in, so that the validation
can be carried out. For example, i place the validation in the Key Up event
handler of the text box on the main application form, and then within the SIP
form, i can fire the Key Up event of the text box.
However, you cannot do this in C#. You can call an event of a class
directly only from within the class itself.
Therefore, i then tried extending the TextBox class into TextBoxExt, and in
TextBoxExt added a method FireKeyUp. I can then call the FireKeyUp method of
my extended class which calls the KeyUp event of its base class.
This is OK in theory (and works perfectly in the full framework), but when I
change the definition in my main form's text box from
System.Windows.Forms.TextBox to TextBoxExt - it disappears from the designer.
I think this is because of the compact framework's lack of support for
designing user controls, etc.
So if i was in VB.net, i could use RaiseEvent, and if I was in the full
framework in c#, i could use a user control/inherited class.
Any suggestions welcome!
Thanks.