欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#實(shí)現(xiàn)讓ListBox適應(yīng)最大Item寬度的方法

 更新時(shí)間:2015年05月16日 15:18:35   作者:永遠(yuǎn)愛好寫程序  
這篇文章主要介紹了C#實(shí)現(xiàn)讓ListBox適應(yīng)最大Item寬度的方法,涉及ListBox控件的操作技巧,需要的朋友可以參考下

本文實(shí)例講述了C#實(shí)現(xiàn)讓ListBox適應(yīng)最大Item寬度的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

private void button1_Click(object sender, EventArgs e)
{
 for (int i = 1; i <= 16; i++)
 {
  listBox1.Items.Add("TTTTTTTTTTTTTTTTTTTTTTTTTTTTT" + i.ToString());
 }
}
private void button2_Click(object sender, EventArgs e)
{
 SizeF size = listBox1.CreateGraphics().
 MeasureString(listBox1.Items[0].ToString(), listBox1.Font);
 MessageBox.Show(Convert.ToInt32(size.Width).ToString());
 listBox1.Width = Convert.ToInt32(size.Width)+20;
}

同理CheckedListBox也可以這樣控制

希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論