积极答复者
为什么winform里的listview控件标题字体大小不能设置?????????????????????

问题
答案
全部回复
-
-
-
this.listView1.OwnerDraw = true;
this.listView1.View = System.Windows.Forms.View.Details;
this.listView1.DrawColumnHeader += new System.Windows.Forms.DrawListViewColumnHeaderEventHandler(this.listView1_DrawColumnHeader);
this.listView1.DrawItem += new System.Windows.Forms.DrawListViewItemEventHandler(this.listView1_DrawItem);
this.listView1.DrawSubItem += new System.Windows.Forms.DrawListViewSubItemEventHandler(this.listView1_DrawSubItem);
private void listView1_DrawColumnHeader(object sender, DrawListViewColumnHeaderEventArgs e)
{
using (StringFormat sf = new StringFormat())
{
// Store the column text alignment, letting it default
// to Left if it has not been set to Center or Right.
switch (e.Header.TextAlign)
{
case HorizontalAlignment.Center:
sf.Alignment = StringAlignment.Center;
break;
case HorizontalAlignment.Right:
sf.Alignment = StringAlignment.Far;
break;
}// Draw the standard header background.
e.DrawBackground();// Draw the header text.
using (Font headerFont =
new Font("Helvetica", 10, FontStyle.Bold))
{
e.Graphics.DrawString(e.Header.Text, headerFont,
Brushes.Black, e.Bounds, sf);
}
}
return;}
private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e)
{
e.DrawDefault = true;
}private void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
e.DrawDefault = true;
}
http://feiyun0112.cnblogs.com/ -
在设计的时候,ColumnHeader的确没被设定成能改变字体。
谢谢你的建议!
这可能对你的程序开发造成了一定的困扰,你可以进入以下的链接,对Visual Studio的使用提出你的反馈和建议。
https://connect.microsoft.com/VisualStudio
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.