有哪位高手知道Combobox文本怎么居中。。急。。 combobox文本居中。。高手指教。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你可以自己写一个combobox继承于Combobox private void comboBox1_DrawItem(object sender, DrawItemEventArgs e) { string s = this.comboBox1.Items[e.Index].ToString(); SizeF ss = e.Graphics.MeasureString(s, e.Font); float l = (float)(e.Bounds.Width - ss.Width) / 2; if (l < 0) l = 0f; float t = (float)(e.Bounds.Height - ss.Height) / 2; if (t < 0) t = 0f; t = t + this.comboBox1.ItemHeight*e.Index; e.DrawBackground(); e.DrawFocusRectangle(); e.Graphics.DrawString(s, e.Font, new SolidBrush(e.ForeColor), l, t); }设置: this.comboBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; 菜鸟问:窗体能够一下子显示在屏幕上,才算加载完毕吗? 声音文件的分割和合成 请教我的编译器是vs.net2005,装framework3会不会出现问题 先安装vs2005还是先装sql server 在pictureBox1上绘制象棋棋盘少了一根线,有人帮帮我看看?奇怪的是在单击就可以了??? 如何用c#写一个对c与语言的编译器呢 .net安装制作中桌面快捷方式的问题 伪随机数问题 200分,200分求QQ2009自定义皮肤功能如何实现,c# c# winform问题 dataGridView 进行一次操作后如何自动读取下一条? datagridview 中改变行的位置
{
string s = this.comboBox1.Items[e.Index].ToString();
SizeF ss = e.Graphics.MeasureString(s, e.Font); float l = (float)(e.Bounds.Width - ss.Width) / 2;
if (l < 0) l = 0f;
float t = (float)(e.Bounds.Height - ss.Height) / 2;
if (t < 0) t = 0f;
t = t + this.comboBox1.ItemHeight*e.Index;
e.DrawBackground();
e.DrawFocusRectangle();
e.Graphics.DrawString(s, e.Font, new SolidBrush(e.ForeColor), l, t);
}
设置:
this.comboBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;