PoovenM 30 Junior Poster

I'm creating a custom ComboBox that allows the user to select a date; the calendar display is localized making the built-in DateTimePicker undesirable (see here for more information). I need the UI control to mirror the look and feel or the existing components. Here's what I've tried and the problems I've encountered:

  • Using a TextBox with a drawn ComboBox button: I've tried using ComboBoxRenderer.DrawDropDownButton but the look and feel does not mirror the existing UI controls. In particular we don't have Application.EnableVisualStyles() so the buttons have a Windows 98 look and feel. ComboBoxRenderer draws a glossy grey button.
  • Using a ComboBox and a ToolStripDropDown to contain the calender control: the button has the correct look and feel but I cannot hide the drop down box completely. Even though the ToolStripControlHost is effectively hiding the drop down box, when I click the button, I can see the drop down box being rendered just before the ToolStripDropDown is displayed. I've tried workarounds that effectively disable the drop down box but the button, as you would expect, does not maintain the desired visual state of being pressed (and drawing the button brings me back to the problem in the above point). Setting the height of the drop down box to zero in OnMeasureItem does not work; though I suppose I could make the drop down box the same height as my calendar UI selector so that the rendering doesn't look particularly bad.

Are there existing mechanisms to get the behaviour I need: a TextBox that displays the selected date with a drop down arrow button that, when clicked, displays a calendar UI selection component. The calendar component already exists and the button must look like the existing Windows 98 look and feel ComboBox buttons.

Thank you for your time and assistance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.