本文主要是介绍gridcontrol单元格边框重绘 加宽显示,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
效果图如下:
正文如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System . Drawing . Drawing2D;
using System . Reflection;
using DevExpress . Utils . Paint;
using System . Diagnostics;namespace text
{public partial class XtraForm2 : DevExpress.XtraEditors.XtraForm{public XtraForm2 ( ){InitializeComponent( );}private void XtraForm2_Load ( object sender , EventArgs e ){FieldInfo fi = typeof ( XPaint ) . GetField ( "graphics" , BindingFlags . Static | BindingFlags . NonPublic );fi . SetValue ( null , new MyXPaint ( ) );}}//选中单元格边框变宽public class MyXPaint :XPaint{public override void DrawFocusRectangle ( Graphics g , Rectangle r , Color foreColor , Color backColor ){base . DrawFocusRectangle ( g , r , foreColor , backColor );if ( !CanDraw ( r ) )return;Brush hb = Brushes . Black;g . FillRectangle ( hb , new Rectangle ( r . X , r . Y , 2 , r . Height - 2 ) );//Leftg . FillRectangle ( hb , new Rectangle ( r . X , r . Y , r . Width - 2 , 2 ) );//Topg . FillRectangle ( hb , new Rectangle ( r . Right - 2 , r . Y , 2 , r . Height - 2 ) );//Rightg . FillRectangle ( hb , new Rectangle ( r . X , r . Bottom -2 , r . Width - 2 , 2 ) );//Bottom }}
}
希望对您有所帮助,若有错误之处,敬请指出,谢谢!
这篇关于gridcontrol单元格边框重绘 加宽显示的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!