﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » ComboBox Item with Graphic</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Sun, 20 Sep 2026 02:24:38 GMT</lastBuildDate><ttl>20</ttl><item><title>ComboBox Item with Graphic</title><link>http://forum.strataframe.net/FindPost25136.aspx</link><description>I have a list of codes in a combobox.  Some of the codes are inactive.  Can I place a graphic next to a code that is inactive?  If so, how do I get there?  The combobox is populated by a business object.&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
Bill</description><pubDate>Tue, 10 Nov 2009 11:07:41 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: ComboBox Item with Graphic</title><link>http://forum.strataframe.net/FindPost25164.aspx</link><description>Glad you're getting it figured out.  I'll mention that an easier alternative to putting a graphic beside the item is to instead just change the color/font of the text of the item. &lt;br&gt;
&lt;br&gt;
As to indenting within code posted here on the forum, the only way I've figured out how to do it is to use the html code for a non-breaking space.  However, be warned that if you do a preview, they disappear in the editor window, so copy the text before previewing and paste right after.</description><pubDate>Tue, 10 Nov 2009 11:07:41 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: ComboBox Item with Graphic</title><link>http://forum.strataframe.net/FindPost25162.aspx</link><description>I'll work on introducing a graphic later.  I need to bask in the shadow of this mini-victory for a while.  :w00t:</description><pubDate>Tue, 10 Nov 2009 09:03:58 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: ComboBox Item with Graphic</title><link>http://forum.strataframe.net/FindPost25161.aspx</link><description>(apologies for the lack of code indenting...it was indented when I posted)&lt;br&gt;
&lt;br&gt;
:blink:</description><pubDate>Tue, 10 Nov 2009 09:02:29 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: ComboBox Item with Graphic</title><link>http://forum.strataframe.net/FindPost25160.aspx</link><description>With your suggestion, I was able to manipulate the text's appearance of an individual item.  Here is my resulting code:&lt;br&gt;
&lt;br&gt;
[codesnippet]&lt;br&gt;
private void CarrierCBE_DrawItem(object sender, DevExpress.XtraEditors.ListBoxDrawItemEventArgs e)&lt;br&gt;
{&lt;br&gt;
    String mCarrierName = (String)e.Item;&lt;br&gt;
    if (mCarrierName == null) return;&lt;br&gt;
&lt;br&gt;
    if (carriersBO1.Seek(String.Format("CarrierName = '{0}'", mCarrierName)))&lt;br&gt;
    {&lt;br&gt;
        if (carriersBO1.Inactive)&lt;br&gt;
        {&lt;br&gt;
            e.Appearance.ForeColor = Color.Gray;&lt;br&gt;
            e.Appearance.Font = new Font("Tahoma", 8.25F, FontStyle.Italic);&lt;br&gt;
        }&lt;br&gt;
        else&lt;br&gt;
        {&lt;br&gt;
            if (carriersBO1.Division == Enumerations.Division.Corporate)&lt;br&gt;
                e.Appearance.ForeColor = Color.Blue;&lt;br&gt;
        }&lt;br&gt;
    }&lt;br&gt;
}&lt;br&gt;
[/codesnippet]&lt;br&gt;
&lt;br&gt;
Thanks for your help!!&lt;br&gt;
Bill</description><pubDate>Tue, 10 Nov 2009 09:01:30 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: ComboBox Item with Graphic</title><link>http://forum.strataframe.net/FindPost25157.aspx</link><description>You'd use the e.Index to access the item in the combo. If I recall (I have to check every time I do this), it is a DataRowView with two columns: name and value. The value is typically setup to be the PK of the item in the BO (its value is determined by the population list settings for the combo). When doing something like this, I'd typically use CopyDataFrom in order to keep data available for this method.&lt;br&gt;
&lt;br&gt;
[codesnippet]protected override void OnDrawItem(DrawItemEventArgs e)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;//-- Get the item, cast to DataRowView.&lt;br&gt;
&amp;nbsp;&amp;nbsp;var item = this.Items[e.Index] as DataRowView;&lt;br&gt;
&amp;nbsp;&amp;nbsp;if(item == null) return;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;//-- Get necessary data from BO...assuming used CopyDataFrom&lt;br&gt;
&amp;nbsp;&amp;nbsp;//&amp;nbsp;&amp;nbsp;&amp;nbsp;so data is already loaded somewhere.&lt;br&gt;
&amp;nbsp;&amp;nbsp;int id = (int)item.Item["value"];&lt;br&gt;
&amp;nbsp;&amp;nbsp;this.MyBO.SeekToPrimaryKey(id);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;//-- Make decisions, draw item....&lt;br&gt;
}&lt;br&gt;
[/codesnippet]</description><pubDate>Mon, 09 Nov 2009 16:09:56 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: ComboBox Item with Graphic</title><link>http://forum.strataframe.net/FindPost25153.aspx</link><description>That does seem like the direction I need to go.  How do I access the BO that I am basing the ComboBox on?  I am trying to access the inactive field of the BO during that method--DrawItem.</description><pubDate>Mon, 09 Nov 2009 12:20:43 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: ComboBox Item with Graphic</title><link>http://forum.strataframe.net/FindPost25146.aspx</link><description>Bill,&lt;br&gt;
&lt;br&gt;
I think you have to use owner drawing. I found this at StackOverflow:&lt;br&gt;
&lt;br&gt;
[url]http://stackoverflow.com/questions/1286248/drop-down-image-list-in-winforms[/url]&lt;br&gt;
&lt;br&gt;
Looks like a bit of work, but doable.</description><pubDate>Mon, 09 Nov 2009 10:26:17 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item></channel></rss>