Datagridview外边框颜色? [英] Datagridview outside border color?

查看:156
本文介绍了Datagridview外边框颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Datagridview outside border color?   BorderStyle= FixedSingle 





我可以找到数据网格的边框颜色



帮助?



我尝试了什么:





I can find Border Color for datagrid

Some help?

What I have tried:

BorderStyle= FixedSingle

推荐答案

据我所知,没有内置方法来改变DataGridView组件边框的颜色。 />


尝试在面板中放置一个DataGridView,将DataGridView的 Dock 属性更改为 Dock.Fill 。现在,更改面板的背景颜色。由于Panel的Padding(1像素)在所有边缘上,你会看到一个DataGridView周围的边框。



另一种方法是覆盖 OnPaint()方法 [ ^ ]用于DataGridView组件。不要忘记在你的代码之前打电话给 base.OnPaint(e)





详情请见:如何:在Windows窗体DataGridView控件中更改边框和网格线样式Microsoft Docs [ ^ ]

覆盖OnPaint方法| Microsoft Docs [ ^ ]

渲染Windows窗体控件| Microsoft Docs [ ^ ]

Control.OnPaintBackground(PaintEventArgs)方法 [ ^ ] - 可能比 OnPaint快;)
As far as i know, there's no inbuilt method to change color of border of DataGridView component.

Try to place a DataGridView inside a Panel, change DataGridView's Dock property to Dock.Fill. Now, change a background color for panel. Due to Panel's Padding (of 1 pixel) on all edges, you'll see a border around the a DataGridView.

Another way is to override the OnPaint() method[^] for DataGridView component. Do not forget to call base.OnPaint(e) before your code!


For further details, please see: How to: Change the Border and Gridline Styles in the Windows Forms DataGridView Control | Microsoft Docs[^]
Overriding the OnPaint Method | Microsoft Docs[^]
Rendering a Windows Forms Control | Microsoft Docs[^]
Control.OnPaintBackground(PaintEventArgs) Method[^] - may be faster than OnPaint ;)


1。将Panel放在Form上,将其BackgroundColor属性设置为您想要的边框颜色。将Panel的Padding属性设置为所需边框的大小。



2.将DataGridView粘贴到Panel中。将其Dock属性设置为Fill。



您可以操作Panel和DataEridView的BorderStyle属性来实现不同的视觉效果。
1. Put a Panel on your Form, set its BackgroundColor property to the border color you want. Set the Panel's Padding property to the size of the border you want.

2. Paste the DataGridView inside the Panel. Set its Dock property to Fill.

You can manipulate the BorderStyle property of both Panel and DataEridView to achieve different visual effects.


这篇关于Datagridview外边框颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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