|
发表于 2020-7-16 11:18:00
|
显示全部楼层
供楼主参考,不是很完善:
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- comboBox1.DrawMode = DrawMode.OwnerDrawFixed;
- }
- protected override void OnLoad(EventArgs e)
- {
- comboBox1.Items.Add("Hello, world!");
- comboBox1.Items.Add("Hello, world!");
- comboBox1.Items.Add("Hello, world!");
- comboBox1.Items.Add("Hello, world!");
- comboBox1.Items.Add("Hello, world!");
- comboBox1.Items.Add("Hello, world!");
- base.OnLoad(e);
- }
- private void button1_Click(object sender, EventArgs e)
- {
- }
- private void comboBox1_DrawItem(object sender, DrawItemEventArgs e)
- {
- string demostr = "51/0x33(0xEA)";
- if ((e.State & DrawItemState.ComboBoxEdit)==DrawItemState.None)
- {
- e.DrawBackground();
- }
- e.Graphics.DrawString(demostr, e.Font, Brushes.Black, e.Bounds.Location);
- SizeF sz = e.Graphics.MeasureString("51/", e.Font);
- PointF pos = e.Bounds.Location;
- pos.X += sz.Width - 6;
- e.Graphics.DrawString("0x33", e.Font, Brushes.Red, pos);
- }
- }
- }
复制代码 |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|