ondrawitem

How to make a custom ComboBox (OwnerDrawFixed) looks 3D like the standard ComboBox?

拥有回忆 提交于 2019-12-30 04:42:07
问题 I am making a custom ComboBox, inherited from Winforms' standard ComboBox. For my custom ComboBox, I set DrawMode to OwnerDrawFixed and DropDownStyle to DropDownList . Then I write my own OnDrawItem method. But I ended up like this: How do I make my Custom ComboBox to look like the Standard one? Update 1: ButtonRenderer After searching all around, I found the ButtonRenderer class. It provides a DrawButton static/shared method which -- as the name implies -- draws the proper 3D button. I'm

Overriding DrawItem for ListBox - unselected items are not redrawn

删除回忆录丶 提交于 2019-12-23 12:59:51
问题 This is a C# desktop application. The DrawStyle property of my ListBox is set to OwnerDrawFixed . The problem: I override DrawItem to draw text in different fonts, and it works. But when I start resizing the form at the runtime, the selected item is drawn correctly, but the rest of them are not redrawn, causing text looking corrupt for unselected items. Here's my code: private void listDevices_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); string textDevice = ((ListBox

Can I use a DrawItem event handler with a CheckedListBox?

允我心安 提交于 2019-11-28 11:33:06
问题 I would like to override the text displayed when an item is added to a checked list box. Right now it is using obj.ToString(), but I want to append some text, without changing the objects ToString method. I have seen examples of handling the DrawItem event for ListBoxs, but when I try to implement them, my event handler is not called. I have noted that the Winforms designer does not seem to allow me to assign a handler for the DrawItem event. Being stubborn, I just added the code myself