473,406 Members | 2,217 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,406 software developers and data experts.

Event Processing

I am attempting to handle an event when the Text changes in a
ToolStripComboBox. I'm just not quite there yet, and hope you can help.
Here's what I have:

namespace Flash
{
class MyComboBox : ToolStripComboBox
{
private MyComboBox()
{
// Code to initialize dropdown list
}

}

class RespondToChange
{
public void Update(object source, ToolStripItemEventArgs e)
{
// My code
}
}

private void Form1_Load(object sender, EventArgs e)
{
MyComboBox myComboBox = new MyComboBox();
RespondToChange doChange = new RespondToChange();

// Note that I am relying on members in the inherited
ToolStripComboBox to accomplish this
// I receive the following error: Cannot implicitly convert type
'System.Windows.Forms.ToolStripItemEventHandler' to 'System.EventHandler'
myComboBox.TextUpdate += new ToolStripItemEventHandler(doChange.Update);
}
}

I have read everything I can find on event handlers, but they never seem to
deal with inherited classes, so I am a bit confused.

Thanks in advance.
Nov 17 '05 #1
3 1651
Hi,
First you dont need to create a new class derived from ToolStripComboBox ,
you just create the instance in the form.

The same apply to RespondToChange class, the Update method can be a method
of the form where the control is created

This does not apply of course if you do not post all the code and you
decided to do it that way for some other reasons you do not explain.

The error you are getting is cause TextUpdate event is of type EventHandler,
not ToolStripItemEventHandler

Check your doc or take a look in the object browser to see the declaration
of it.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"wschlichtman" <ws**********@discussions.microsoft.com> wrote in message
news:D1**********************************@microsof t.com...
I am attempting to handle an event when the Text changes in a
ToolStripComboBox. I'm just not quite there yet, and hope you can help.
Here's what I have:

namespace Flash
{
class MyComboBox : ToolStripComboBox
{
private MyComboBox()
{
// Code to initialize dropdown list
}

}

class RespondToChange
{
public void Update(object source, ToolStripItemEventArgs e)
{
// My code
}
}

private void Form1_Load(object sender, EventArgs e)
{
MyComboBox myComboBox = new MyComboBox();
RespondToChange doChange = new RespondToChange();

// Note that I am relying on members in the inherited
ToolStripComboBox to accomplish this
// I receive the following error: Cannot implicitly convert type
'System.Windows.Forms.ToolStripItemEventHandler' to 'System.EventHandler'
myComboBox.TextUpdate += new
ToolStripItemEventHandler(doChange.Update);
}
}

I have read everything I can find on event handlers, but they never seem
to
deal with inherited classes, so I am a bit confused.

Thanks in advance.

Nov 17 '05 #2
You are correct, I did not post all the code. I am attempting to create a
ComboBox that, once instantiated, is already filled with font names that are
available on the current system. I have this part working properly.

My goal is to retrieve the font name from the combobox as soon as the user
selects a new font. I can then change the font in a separate textbox that is
located on the main form of the application.

As for the TextUpdate event, I have not been able to find the correlating
event handler in the ToolStripComboBox. This item seems to be part of .NET
2.0 and .NET 1.1 SDK documentation is still posted on the web. I have browsed
the objects, and find that TextUpdate is indeed an element of
ToolStripComboBox, and as you say, it is of type System.EventHandler. My
question then is how do I resolve this?

Sorry for my ignorance. I am returning to programming after many years in
tech support.
This does not apply of course if you do not post all the code and you
decided to do it that way for some other reasons you do not explain.

The error you are getting is cause TextUpdate event is of type EventHandler,
not ToolStripItemEventHandler


Nov 17 '05 #3
Hi,
As for the TextUpdate event, I have not been able to find the correlating
event handler in the ToolStripComboBox. This item seems to be part of .NET
2.0 and .NET 1.1 SDK documentation is still posted on the web. I have
browsed
the objects, and find that TextUpdate is indeed an element of
ToolStripComboBox, and as you say, it is of type System.EventHandler. My
question then is how do I resolve this?

Simple, first you do not need to derive ToolStripComboBox , just create a
new instance of it, then change the Update method to have the EventHandler
signature. Then handle the SelectedIndexChanged of the combobox there you
can know the selected item and just do the appropiate to change the TextBox
with the font selected.


cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Nov 17 '05 #4

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

Similar topics

4
by: Bob | last post by:
Below is sample code that illustrates what I'm trying to do. For sake of brevity I didn't include the properties of buildBtn that determine what data to request. The problem is I never see...
3
by: Kent | last post by:
The following is a greatly simplified example of what I would like to accomplish using the event/delegate features of .NET I have a class "NumGen" that produces a random set of numbers between 0...
0
by: anonymous | last post by:
Thanks Michelle, How could I achieve the second one.I do not like Flashing windows in response to selection of an item. I agree the data transfer is very little but the same data transferred for...
2
by: Steven ONeil | last post by:
I'm trying to process the Onclick event of my page but it's never working. The button is dynamical added to the sites MainPanel. If I click on the button the PageLoad Event is processed but no event...
3
by: Bruce HS | last post by:
When I raise an event in an ancestor, the event fires first in the ancestor, then its descendant, and then in the descendant's descendant. I would like the descendant's descendant to fire first...
0
by: Conrad | last post by:
Greetings, For user actions on a wxWidget that trigger multiple events for that wxWidget, is the order those events are processed in undefined, and therefore arbitrary from one platform (ie...
1
by: mailpitches | last post by:
X-No-Archive: yes a function, the return value of the function is a boolean. What does this boolean value mean? Example: <body onload="document.getElementById('field').onkeydown=function(x) {...
2
by: JohnR | last post by:
I know about AddHandler and RemoveHandler, but my requirement is a little more complex. I pass a form to a routine. In that routine I must scan each control, and for each "button" control I find,...
2
by: msch.prv | last post by:
Thanks for bearing with me. I am confronted with huge hidden viewstates fields in some pages and looking for ways to make these pages leaner. My problem hinges on how to efficiently handle...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.