关于ComboBox一问?

javaduke 2002-02-04 09:47:53
我使用DrawItem使comboBox的下拉项目可以加上图标显示,但是如何在选中的项目显示中加入图标呢?
...全文
62 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yigenhuochai 2002-02-18
  • 打赏
  • 举报
回复
收藏先
rainbow 2002-02-05
  • 打赏
  • 举报
回复
if(e.state&itemstate.selected)
rainbow 2002-02-05
  • 打赏
  • 举报
回复
还要修改属性
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
rainbow 2002-02-05
  • 打赏
  • 举报
回复
这样行不行?
private void comboBox1_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
{

Graphics g=e.Graphics;
System.Drawing.Icon[] myIcon={
new System.Drawing.Icon(@"D:\vc\prgbar\icon1.ico"),
new System.Drawing.Icon(@"D:\vc\prgbar\small.ico"),
new System.Drawing.Icon(@"D:\vc\prgbar\prgbar.ico")
};
for(int i=0;i<3;i++)
{
g.DrawIcon(myIcon[i],2,i*14);
//g.DrawString(....);
}
if((e.State&DrawItemState.ComboBoxEdit)>0)
{
int ii=Math.Max(0,e.Index);
g.Clear(System.Drawing.Color.FromArgb(255,255,255));
g.DrawIcon(myIcon[ii],2,0);
//g.DrawString(...);

}
}
tms2000 2002-02-05
  • 打赏
  • 举报
回复
自己划呀
javaduke 2002-02-05
  • 打赏
  • 举报
回复
我不是指的这个意思。我是指选中以后。comboBox框中显示的东东带有图标。

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧