码迷,mamicode.com
首页 > 其他好文 > 详细

cxGrid的FilterRow默认自动匹配左边%而不是右边%

时间:2018-03-04 11:57:15      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:mod   copyto   必须   word   name   res   set   begin   row   

/==============================================================================
// 修改cxGrid的FilterRow过滤框的默认值为左匹配
//==============================================================================

1、建立一个公共储存过程,如果有其他Unit需要的话必须做全局声明。

procedure SetCustomFilterRow(cxGridDBBandedTableView: TcxGridDBBandedTableView);
var
  I: Integer;
  S: string;
begin
  with cxGridDBBandedTableView, ViewData do
  begin
    if FilterRow.Focused then
    begin
      for I := 0 to ColumnCount - 1 do
      begin
        S := VarToStr(FilterRow.Values[I]);
        if (Length(S)> 0) and (S[1] <> ‘%‘) then
          FilterRow.Values[I] := ‘%‘ + S;
      end;
    end;
  end;
end;

 

2、选择cxGrid中的TcxGridDBBandedTableView,找到Events中的DataContoller的Filter的OnChanged,双击后增加调用修改函数的代码

procedure TFormMainOperation.cxgrddbbandtv1DataControllerFilterChanged(
  Sender: TObject);
begin
  SetCustomFilterRow(cxgrddbbandtv1);
end;

说明:cxgrddbbandtv1是本人实际程序中的cxGrid中的cxGridDBBandedTableView的Name

           TFormMainOperation是本人实际程序中Form的Name

           如果只有一个Form使用可以修改公共调用函数,增加“TFormXXXX.”这样更简单

 

注意:右匹配%是否自动带出取决于:选择cxGrid中的TcxGridDBBandedTableView,找到Properties中的DataContoller的Filter的PercentWildcard(默认%一般不需要修改)和SupportedLike(真正起效果的属性)

TcxGridDBBandedTableView.DataController.Filter.Options :=[fcoCaseInsensitive];//不区分大小写

 

 

 

Using a checkbox at runtime to make FilterRow Visible/Invisible通过checkbox来控制是否显示

[delphi] view plain copy
 
  1. procedure TForm1.CheckBox1Click(Sender: TObject);  
  2. begin  
  3.   cxGrid1DBTableView1.FilterRow.Visible := CheckBox1.Checked;  
  4. end;  

 

控制焦点是否在FilterRow上

[delphi] view plain copy
 

ViewData.FilterRow.Focused := True;  

 

cxGrid的FilterRow默认自动匹配左边%而不是右边%

标签:mod   copyto   必须   word   name   res   set   begin   row   

原文地址:https://www.cnblogs.com/westsoft/p/8503880.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!