473,657 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom ComboBox

Hi
I want to design a combo box.
I open a new UserControl project and inherits from
System.Windows. Forms.ComboBox
and try to override OnPaint event and set the DrawMode to OwnerDrawFixed.
But when I compile the project the interface did not change.
How can I override the OnPaint of this component.
Thanks in advance.
Nov 16 '05 #1
2 7067
Mohammad,

When you set the DrawMode to OwnerDrawFixed, I believe that the event
will fire the DrawItem and the MeasureItem events, which you hook up to and
then provide painting code in there.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Mohammad-Reza" <mr********@hot mail.com> wrote in message
news:OI******** ******@TK2MSFTN GP15.phx.gbl...
Hi
I want to design a combo box.
I open a new UserControl project and inherits from
System.Windows. Forms.ComboBox
and try to override OnPaint event and set the DrawMode to OwnerDrawFixed.
But when I compile the project the interface did not change.
How can I override the OnPaint of this component.
Thanks in advance.

Nov 16 '05 #2
MeasureItem and DrawItem both are for drop down items and I want to change
the user interface of the control.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:uJ******** ******@TK2MSFTN GP15.phx.gbl...
Mohammad,

When you set the DrawMode to OwnerDrawFixed, I believe that the event
will fire the DrawItem and the MeasureItem events, which you hook up to and then provide painting code in there.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Mohammad-Reza" <mr********@hot mail.com> wrote in message
news:OI******** ******@TK2MSFTN GP15.phx.gbl...
Hi
I want to design a combo box.
I open a new UserControl project and inherits from
System.Windows. Forms.ComboBox
and try to override OnPaint event and set the DrawMode to OwnerDrawFixed. But when I compile the project the interface did not change.
How can I override the OnPaint of this component.
Thanks in advance.


Nov 16 '05 #3

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

Similar topics

0
2055
by: jean | last post by:
hi: i am developing a custom combobox for my company's needs that is made up of a textbox, listbox, button. i am using c#. everything is fine except for one issue. in a normal combobox, when the dropdown is visible and the user clicks anywhere else, the dropdown gets hidden. i am trying to replicate this behavior and have tried using the Leave and LostFocus events. i have had marginal success when my dropdown is visible and i...
10
2201
by: Judy | last post by:
How do I create a combobox in a custom menubar to display months like: 1 January 2 February 3 March etc and then assign the month number (1, 2, 3, etc) of the selected month to a textbox on a form? Thanks for all help!
0
1533
by: metamedia | last post by:
How do I get a datagrid to register a data change from a custom control cell (combobox) I've got a Windows Application with a Windows Form Datagrid that has a custom combobox column. When the user clicks on a new row in the datagrid and tries to select or enter a new value in the combobox, the datagrid doesn't seem to register the change, so if the user tabs through the columns and onto the next row, the data is cleared and not saved Does...
2
2088
by: John B | last post by:
Hello I want to create a set of controls that have some common methods and properties. I was thinking that I should subclass the UserControl class and add these common features there and then base all my custom controls on this new MyUserControl Class. Is this the way to go? The MyUserControl would not actually have any UI component and should be abstract I think. Does this mena that I should not create the control by just selecting...
3
2189
by: Flack | last post by:
Hello, I am beginning to write a custom combobox control. Right now it doesn't do anything special. I created a class that extends ComboBox: public class TimeSelector : System.Windows.Forms.ComboBox and in its constructor I call Populate: public TimeSelector()
1
3702
by: Marty Cruise | last post by:
I have a custom collection which contains instances of a custom class. With me so far? OK, now I set the datasource of a combobox to the collection, having overridden the ToString() function of the custom class to return one of its text properties. Life is good. The first of two problems involves the combobox showing the first item in the collection. To get around this,
5
2148
by: ross kerr | last post by:
Hi All, I am extending the combobox to create a control that selects an item based on the text the user is typing into the text area of the control. I have an issue that occurs only when i drop down the combo box as the users typing. When the on leave event is fired the value in the selected
2
1409
by: Don | last post by:
I've been trying to create a custom collection that can be bound to a combobox via the DataSource property, but I can't seem to get it to work. I've created a class that implements IList, and it seems to work okay on its own, but when I try to bind it to a combobox, the combobox doesn't show anything (and it starts having problems repainting itself). The Datasource appears to contain my custom collection object, but when I ask for its item...
8
3515
by: mongphong28 | last post by:
Hi, I'm populating a ComboBox with objects which contain two properties - IntegerValue and StringValue. I display StringValue in the ComboBox form and can retrieve IntegerValue from the SelectItem.IntegerValue property. This is all good but now I want to get a little bit more complicated. I want to be able to set the ComboBox's SelectedItem property by setting IntegerValue, so for instance if I have the following items in
8
13095
by: g_man | last post by:
I am trying trap Runtime error 3022 (duplicates) in the click event of a command button that closes the form. I have code in the Form_Error event that does a good job of providing a more meaningful error message than the default. It works in every situation except when the user clicks the close button. I am using Me.Dirty=False to force a save but if there are duplicates I just get the standard Runtime 3022 error message. I am wondering...
0
8411
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8323
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8838
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8513
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8613
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7351
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2740
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.