C# Form窗体中的comboBox1简单问题!!谢谢!! 不好修改,自己写一个combobox吧,我这有一个,可惜东西太多,发不上来 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 当ComboBox的DrawMode设置为非Normal的时候,它的高度是由ItemHeight来决定的,但是这个时候可能ComboBox的Items要求重绘. 楼主可以试试:comboBox1.DrawMode=OwnerDrawVariable;comboBox1.ItemHeight=50;看看是不是高度变高了. 对于重绘,可以参考如下的代码:using System;using System.Collections.Generic;using System.Text;using System.Windows.Forms;using System.Drawing;namespace TestApp{ class combox:ComboBox { public combox() { this.DrawMode = DrawMode.OwnerDrawVariable; this.ItemHeight = 60; } protected override void OnMeasureItem(MeasureItemEventArgs e) { e.ItemHeight = 20; e.ItemWidth = 200; base.OnMeasureItem(e); } protected override void OnDrawItem(DrawItemEventArgs e) { base.OnDrawItem(e); using (SolidBrush brush = new SolidBrush(e.ForeColor), backBrush=new SolidBrush(e.BackColor)) { e.Graphics.FillRectangle(backBrush, e.Bounds); e.Graphics.DrawString(this.Items[e.Index].ToString(), this.Font, brush, e.Bounds); } } }} 很具挑战性的一组数字循环输出问题 请问,下列问题中VB6的LenB函数,在vb.net和C#中该如何替换。请看VB6代码: 刚才叙述不清,是这样的一个简单问题! 求C#屏蔽快捷键代码. 如何按顺序读取XML文件 *********工作线程和主线程的通信问题***********急急急!!!! C#笔试题,高分求教,求好心人帮忙!!!! 获取网络图片的大小和尺寸 Text='<%# DataBinder.Eval(Container, "DataItem.employeeid") %> 具体是什么意思啊 c# 海康卫视车牌识别 如何用C#将EXCEL文件转化为XML文档 解决后50分!!!
但是这个时候可能ComboBox的Items要求重绘.
comboBox1.DrawMode=OwnerDrawVariable;
comboBox1.ItemHeight=50;看看是不是高度变高了.
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;namespace TestApp
{
class combox:ComboBox
{
public combox()
{
this.DrawMode = DrawMode.OwnerDrawVariable;
this.ItemHeight = 60;
}
protected override void OnMeasureItem(MeasureItemEventArgs e)
{
e.ItemHeight = 20;
e.ItemWidth = 200;
base.OnMeasureItem(e);
}
protected override void OnDrawItem(DrawItemEventArgs e)
{
base.OnDrawItem(e);
using (SolidBrush brush = new SolidBrush(e.ForeColor), backBrush=new SolidBrush(e.BackColor))
{
e.Graphics.FillRectangle(backBrush, e.Bounds);
e.Graphics.DrawString(this.Items[e.Index].ToString(), this.Font, brush, e.Bounds);
}
}
}
}