在自定义的WinForms ListView的? [英] Custom ListView in Winforms?

查看:157
本文介绍了在自定义的WinForms ListView的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能得出一些字符串到列表视图?

我重写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));
        }

    }

这篇关于在自定义的WinForms ListView的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆