如何改变C#的Panel控件的边框颜色

如何改变C#的Panel控件的边框颜色,第1张

添加一个Panel控件之后,双击就打开了Panel控件的Panit事件处理方法.

private void panel1_Paint(object sender, PaintEventArgs e) 

        { 

            ControlPaint.DrawBorder(e.Graphics, 

                                        panel4.ClientRectangle, 

                                        Color.Red, 

                                        3, 

                                        ButtonBorderStyle.Solid, 

                                        Color.Red, 

                                        3, 

                                        ButtonBorderStyle.Solid, 

                                        Color.Red, 

                                        3, 

                                        ButtonBorderStyle.Solid, 

                                        Color.Red, 

                                        3, 

                                        ButtonBorderStyle.Solid) 

        }

原生的TextBox不支持修改边框颜色,所以你需要重写一个Textbox控件。

参照这里:

http://wenku.baidu.com/view/64910db565ce0508763213ef.html

如果你对于重写控件或者绘制这种技能比较不顺手的话,可以考虑这样:

将TextBox 的边框样式设置为None,然后在其底下放一个PictureBox,PictureBox里放一个大小适中、带边框的图片。

这样看起来就是文本框有了边框了。

然后再为TextBox设置MouseHover事件,改变PictureBox的Image便实现了变色。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11700666.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-18
下一篇2023-05-18

发表评论

登录后才能评论

评论列表(0条)

    保存