Please try this
changed
object comboBoxItem = comboBox3.Items[e.Index];
e.Graphics.DrawString(comboBoxItem.ToString(), comboBox3.Font, textBrush, bounds);
to
DataRowView comboBoxItem = (DataRowView)comboBox1.Items[e.Index];
e.Graphics.DrawString(comboBoxItem["city_desc"].ToString(), comboBox1.Font, textBrush, bounds);
Designer.cs
private void InitializeComponent()
{
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.citymastBindingSource = new System.Windows.Forms.BindingSource(this.components);
this._TestDataSet = new WinTest._TestDataSet();
this.city_mastTableAdapter = new winTest._TestDataSetTableAdapters.city_mastTableAdapter();
this.comboBox1.DataSource = this.citymastBindingSource;
this.comboBox1.DisplayMember = "city_desc";
this.comboBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
this.comboBox1.FormattingEnabled = true;
this.comboBox1.ItemHeight = 25;
this.comboBox1.Location = new System.Drawing.Point(367, 74);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(171, 31);
this.comboBox1.TabIndex = 4;
this.comboBox1.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.comboBox1_DrawItem);
this.citymastBindingSource.DataMember = "city_mast";
this.citymastBindingSource.DataSource = this._TestDataSet;
this._TestDataSet.DataSetName = "_TestDataSet";
this._TestDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema;
this.city_mastTableAdapter.ClearBeforeFill = true;
}
Code.cs
private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
{
Font myFont = new System.Drawing.Font("Comic Sans", 11);
DataRowView comboBoxItem = (DataRowView)comboBox1.Items[e.Index];
e.DrawBackground();
e.DrawFocusRectangle();
using (Brush textBrush = new SolidBrush(e.ForeColor))
{
Rectangle bounds = e.Bounds;
using (StringFormat format = new StringFormat())
{
format.LineAlignment = StringAlignment.Center;
format.Alignment = StringAlignment.Near;
e.Graphics.DrawString(comboBoxItem["city_desc"].ToString(), comboBox1.Font, textBrush, bounds);
}
}
}
}