是否有可能得出一些字符串到列表视图?
我重写OnPaint事件,但我看不出有任何变化。我检查了自定义列表视图约code,但似乎人们都使用P / Invoke等,为什么?
未列出的自定义其他的WinForms,如Button控件?
我不是要去疯狂定制,只是画一些后,它的完成标准的画。
解决方案 类MyCustomlistView:ListView控件
{
公共MyCustomlistView()
: 基础()
{
的SetStyle(ControlStyles.UserPaint,真正的);
}
保护覆盖无效的OnPaint(PaintEventArgs的E)
{
base.OnPaint(E);
e.Graphics.DrawString(这是一个自定义字符串,新的字体(FontFamily.GenericSerif,10,FontStyle.Bold),Brushes.Black,新的PointF(0,50));
}
}
Is it possible to draw some strings onto a listview?
I overridden the OnPaint event but I don't see any change. I checked out some code on custom listview, but it seems like people are using p/invoke, etc. Why?
Isn't list as customizable as other winforms, like the Button control?
I am not gonna customize wildly, just paint some more after it's done the standard painting.
解决方案 class MyCustomlistView : ListView
{
public MyCustomlistView()
: base()
{
SetStyle(ControlStyles.UserPaint, true);
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawString("This is a custom string", new Font(FontFamily.GenericSerif, 10, FontStyle.Bold), Brushes.Black, new PointF(0, 50));
}
}