Windows Graphics, or ComboBox Question.
-
I have 2 questions, and answering either will easily solve a problem. The first, where might I find the lovely bitmaps and such that Microsoft uses in their operating system so that I can use these same ones in my application? Particularly, the arrow button that you see at the ends of slider bars and combo boxes. ~OR~ If I have a combobox with nothing in its list, and I click the dropdown button, how can I prevent the list from showing one blank line? Either answer will help! Thanks a bunch. - D
-
I have 2 questions, and answering either will easily solve a problem. The first, where might I find the lovely bitmaps and such that Microsoft uses in their operating system so that I can use these same ones in my application? Particularly, the arrow button that you see at the ends of slider bars and combo boxes. ~OR~ If I have a combobox with nothing in its list, and I click the dropdown button, how can I prevent the list from showing one blank line? Either answer will help! Thanks a bunch. - D
See the
ControlPaint.DrawComboButton
method in the .NET Framework SDK for one option. Otherwise, you'll need to include bitmaps yourself, either embedding them into a ResX file (using anImageList
in the designer does this for you, which base64-encodes it) or embed them as manifest resources by adding them to your project and changing the build action to "Embedded Resource". You can access these bitmaps (which I use generically for pixel map images) usingAssembly.GetManifestResourceStream
or some methods on theImage
andBitmap
classes allow you to specify a manifest resource from which anImage
orBitmap
(derivative ofImage
) is created. It's important to understand that most of the Windows Forms controls are not implement in .NET, per se. They encapsulate the Windows Common Controls, so it's the native window classes that are being used and which take care of drawing themselves (for the most part).Microsoft MVP, Visual C# My Articles
-
See the
ControlPaint.DrawComboButton
method in the .NET Framework SDK for one option. Otherwise, you'll need to include bitmaps yourself, either embedding them into a ResX file (using anImageList
in the designer does this for you, which base64-encodes it) or embed them as manifest resources by adding them to your project and changing the build action to "Embedded Resource". You can access these bitmaps (which I use generically for pixel map images) usingAssembly.GetManifestResourceStream
or some methods on theImage
andBitmap
classes allow you to specify a manifest resource from which anImage
orBitmap
(derivative ofImage
) is created. It's important to understand that most of the Windows Forms controls are not implement in .NET, per se. They encapsulate the Windows Common Controls, so it's the native window classes that are being used and which take care of drawing themselves (for the most part).Microsoft MVP, Visual C# My Articles
-
I like the ControlPaint.DrawComboButton method, however, why doesn't the OnPaint handler fire in a class inherited from a TextBox? If I change the base class to Label, or another control, the OnPaint handler fires, but not with TextBox...any ideas?
It's not supposed to fire. As I've tried to remind those in this forum many times, most of the Windows Forms controls encapsulate the Windows Common Controls. The
TextBox
encapsulates (wraps) the Edit control, which paints itself and cannot be overridden as many other controls can (like the Static class, which is encapsulated in theLabel
class). Even theListView
doesn't work the same with the call toOnPaint
. In order to custom draw items, you have to handle the right notification messages.Microsoft MVP, Visual C# My Articles