private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { ComboxBoxEx senderComboBox = (ComboxBoxEx)sender; if (senderComboBox.SelectedItem == null) { return; } DataRowView item = (DataRowView)senderComboBox.SelectedItem; }
private void comboBox2_MeasureItem(object sender, MeasureItemEventArgs e) { ComboxBoxEx comboBoxSender = (ComboxBoxEx)sender; DataRowView item = (DataRowView)comboBoxSender.Items[e.Index]; string txt = item["fullInfo"].ToString(); int height = Convert.ToInt32(e.Graphics.MeasureString(txt, comboBoxSender.Font).Height); e.ItemHeight = height + 4; if (e.Index == 0) { e.ItemHeight = 0; } e.ItemWidth = comboBoxSender.DropDownWidth; comboBoxSender.ItemHeights.Add(e.ItemHeight); }
private void comboBox2_DrawItem(object sender, DrawItemEventArgs e) { ComboxBoxEx comboBoxSender = (ComboxBoxEx)sender; //for (int index = 0; index < comboBoxSender.Items.Count; index++) //{ // if (index != 0) // { // ((DataRowView)comboBoxSender.Items[index])["fullInfo"] = ((DataRowView)comboBoxSender.Items[index])["id"]; // } //} DataRowView item = (DataRowView)comboBoxSender.Items[e.Index]; string txt = item["fullInfo"].ToString(); e.DrawBackground(); e.Graphics.DrawString(txt, comboBoxSender.Font, System.Drawing.Brushes.Black, new RectangleF(e.Bounds.X + 2, e.Bounds.Y + 2, e.Bounds.Width, e.Bounds.Height)); //e.Graphics.DrawLine(new Pen(Color.LightGray), e.Bounds.X, e.Bounds.Top + e.Bounds.Height - 1, e.Bounds.Width, e.Bounds.Top + e.Bounds.Height - 1); //e.DrawFocusRectangle(); }