现在的位置: 首页 > 综合 > 正文

[DevExpress控件应用]XtraGrid: 改变当前单元格外框的颜色

2013年10月12日 ⁄ 综合 ⁄ 共 2351字 ⁄ 字号 评论关闭
代码:
using DevExpress.Utils.Paint;

    
public class CustomXPaint : XPaint
    
{
        
public override void DrawFocusRectangle(Graphics g, Rectangle rect, Color foreColor, Color backColor)
        
{
            
if (CanDraw(rect) == false)
                
return;
            Brush brush 
= Brushes.Red;    //红色外框
            g.FillRectangle(brush, new Rectangle(rect.X, rect.Y, 1, rect.Height - 1));          // left
            g.FillRectangle(brush, new Rectangle(rect.X, rect.Y, rect.Width - 11));           // top
            g.FillRectangle(brush, new Rectangle(rect.Right - 1, rect.Y, 1, rect.Height - 1));  // right
            g.FillRectangle(brush, new Rectangle(rect.X, rect.Bottom - 1, rect.Width, 1));      // bottom
        }

    }


    
public partial class Form1 : Form
    
{
        
构造函数
        
画面激活时
        
画面非激活时
    }

如果是只读的查询表格,可以添加如下的代码:

        画面加载时

 

达到行选择的效果。(效果图上传不了)

抱歉!评论已关闭.