<p>I have a control that is modelled on a <strong>ComboBox</strong>. I want to render the control so that the control <strong>border</strong> looks like that of a standard <strong>Windows ComboBox</strong>. Specifically, I have followed the MSDN documentation and all the rendering of the control is correct except for rendering when the control is disabled.</p>

<p>Just to be clear, this is for a system with <strong>Visual Styles</strong> enabled.  Also, all parts of the control render properly except the border around a disabled control, which does not match the disabled <strong>ComboBox border</strong> colour.</p>

<p>I am using the <strong>VisualStyleRenderer</strong> class. MSDN suggests using the <code>VisualStyleElement.TextBox</code> element for the <strong>TextBox</strong> part of the <strong>ComboBox</strong> control but a standard disabled <strong>TextBox</strong> and a standard disabled <strong>ComboBox</strong> draw slightly differently (one has a light grey border, the other a light blue border).</p>

<p>How can I get correct rendering of the control in a disabled state?</p>

[{'answer_id': 13319, 'author': 'Nick', 'author_id': 1490, 'author_profile': 'https://Stackoverflow.com/users/1490', 'pm_score': 1, 'selected': False, 'text': '<p>Are any of the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.controlpaint_members.aspx" rel="nofollow noreferrer">ControlPaint</a> methods useful for this?  That\'s what I usually use for custom-rendered controls.</p>\n'}, {'answer_id': 13372, 'author': 'Patrik Svensson', 'author_id': 936, 'author_profile': 'https://Stackoverflow.com/users/936', 'pm_score': 4, 'selected': False, 'text': '<p>I\'m not 100% sure if this is what you are looking for but you should check out the <strong>VisualStyleRenderer</strong> in the System.Windows.Forms.VisualStyles-namespace.</p>\n\n<ol>\n<li><a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.visualstyles.visualstylerenderer.aspx" rel="noreferrer">VisualStyleRenderer class</a> (MSDN)</li>\n<li><a href="http://msdn.microsoft.com/en-us/library/ms171735.aspx" rel="noreferrer">How to: Render a Visual Style Element</a> (MSDN)</li>\n<li><a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.visualstyles.visualstyleelement.combobox.dropdownbutton.disabled.aspx" rel="noreferrer">VisualStyleElement.ComboBox.DropDownButton.Disabled</a> (MSDN)</li>\n</ol>\n\n<p>Since VisualStyleRenderer won\'t work if the user don\'t have visual styles enabled (he/she might be running \'classic mode\' or an operative system prior to Windows XP) you should always have a fallback to the ControlPaint class.</p>\n\n<pre><code>// Create the renderer.\nif (VisualStyleInformation.IsSupportedByOS \n    &amp;&amp; VisualStyleInformation.IsEnabledByUser) \n{\n    renderer = new VisualStyleRenderer(\n        VisualStyleElement.ComboBox.DropDownButton.Disabled);\n}\n</code></pre>\n\n<p>and then do like this when drawing:</p>\n\n<pre><code>if(renderer != null)\n{\n    // Use visual style renderer.\n}\nelse\n{\n    // Use ControlPaint renderer.\n}\n</code></pre>\n\n<p>Hope it helps!</p>\n'}]
['https://Stackoverflow.com/questions/2874', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/441/']