//自带的cxgrid并能在lookupcombobox中进行多列查询,在其他地方收集到一些资料,可实现多列查询,但只能从某列的开关开始录入,下面是实现的代码,只是我还想要实现模糊查询,若哪位仁兄做出来,望告知
//将cxgride中的lookupcombobox的查询条件修改为可多列查询(查询只能是显示列)
cxCustomData.pas
//修改一
TcxCustomDataController = class(TPersistent, IUnknown)
private
FDisplayIndex: Integer; --添加一个属性
FActive: Boolean;
FAfterSummaryFlag: Boolean;
FBookmarkRecordIndex: Integer;
...
public
property DisplayIndex: Integer read FDisplayIndex write FDisplayIndex; --把属性公布出来
//修改二
function TcxCustomDataController.DoIncrementalFilterRecord(ARecordIndex: Integer): Boolean;
var
S: string;
I: Integer;
begin
Result := False;
for I := 0 to Fields.ItemCount - 1 do
begin
S := GetInternalDisplayText(ARecordIndex, Fields[i]);
Result := DataCompareText(S, FIncrementalFilterText, True);
if Result then
begin
FDisplayIndex := i;
Exit;
end;
end;
//注释掉原来的代码
// S := GetInternalDisplayText(ARecordIndex, FIncrementalFilterField);
// Result := DataCompareText(S, FIncrementalFilterText, True);
end;
cxLookupEdit.pas
//修改一
function TcxCustomLookupEditLookupData.Locate(var AText, ATail: string; ANext: Boolean): Boolean;
function SetGridFilter(AItemIndex: Integer; const AText: string): Integer;
. ..
var
AItemIndex, ARecordIndex: Integer;
S: string;
begin
Result := False;
DisableChanging;
try
AItemIndex := GetListIndex;
if (AItemIndex <> -1) and (DataController <> nil) then
begin
// TODO: Next
if FVisible and Properties.GetIncrementalFiltering {and (Properties.DropDownListStyle <> lsFixedList)} then
ARecordIndex := SetGridFilter(AItemIndex, AText)
else
ARecordIndex := Properties.FindByText(AItemIndex, AText, True);
if ARecordIndex <> -1 then
begin
DataController.ChangeFocusedRecordIndex(ARecordIndex);
DoSetCurrentKey(ARecordIndex);
Result := True;
//此处为添加代码
if DataController.DisplayIndex > -1 then
begin
S := DataController.DisplayTexts[ARecordIndex, DataController.DisplayIndex];
DataController.DisplayIndex := -1;
end
else
begin
S := DataController.DisplayTexts[ARecordIndex, AItemIndex];
end;
//结束
AText := Copy(S, 1, Length(AText));
ATail := Copy(S, Length(AText) + 1, Length(S));
DoSetKeySelection(True);
end
else
DoSetKeySelection(False);
end;
finally
EnableChanging;
end;
end;
//后面这些修改为使能达到模糊查询,效果还要改进
//cxDataUtils.pas
function DataCompareText(const S1, S2: string; APartialCompare: Boolean): Boolean;
var
AText1, AText2: string;
L2: Integer;
begin
AText1 := AnsiUpperCase(S1);
AText2 := AnsiUpperCase(S2);
L2 := Length(AText2);
if L2 = 0 then
Result := Length(AText1) = 0
else
if not APartialCompare then
Result := AText1 = AText2
else
//修改开始begin
//Result := (Length(AText1) >= L2) and (Copy(AText1, 1, L2) = AText2); //原语句
begin
Result := (Length(AText1) >= L2) and (pos(atext2, atext1) > 0);
end;
//修改结束end
end;
分享到:
相关推荐
cxGrid中cxLookupComboBox应用
基于delphi的CxGrid控件一些使用小节,希望与诸位共勉!
cxGrid查找功能
cxGrid 中文教程,内容丰富,希望用的朋友可以下载看看,不错的;
cxgrid 下拉框,很多人不知道怎么在grid数据显示添加时设置下拉框,或许这个可以帮到你。
CheckBox在cxGrid中的应用
cxgrid栅格中操作图片
Delphi 在cxgrid中进行数据统计,OrderBy操作演示,从数据库中读取出记录: procedure TFrmOrderBy.BtnOrderClick(Sender: TObject); var item: TcxGridDBTableSummaryItem; begin item := ...
CXGrid中文教程:详细介绍了控件的用法
cxgrid 拖放移动记录,cxgrid 拖放,cxgrid 拖动记录,cxgrid 鼠标拖动记录 这是cxgrid开发公司回复客户时所发送的源码项目,用于实现鼠标拖动记录,改变记录在表格中的位置,所以直接编译运行,供大家借鉴
cxgrid中文教程_ExpressQuantumGrid 1\table view grid 2\卡片式 3、多表头 4、明细嵌套
cxGrid与cxLookupComboBox多列模糊过滤
代码已示例出cxGrid数据行是如何移动,即将整行记录上移或下移,功能完整,值得拥有。
1. 去掉cxgrid中台头的box ,在tableview1的ptionsview的groupbybox=false; 2. 在GRID footer 中加入sum(列), tableview1的optionsview的footer=ture 然后在cxGRid1的customize..中的summary 的footer.add需要合计的...
设置cxgrid 行的颜色、列的颜色、excel、acc导入功能
由于cxGrid把Hint给封装了(它的Hint须在列宽不够大时才显示,且显示的内容不能随意),使得Hint无法方便地使用,经在cxGrid源码中分析,弄出这个给cxGrid附加格式化Hint的方法,在Delphi6、ExpressQuantumGrid_v5.8...
cxGrid动态实现窗口冻结,cxGrid动态实现窗口冻结
这是cxgrid开发公司回复客户时所发送的源码项目,用于实现鼠标拖动记录,改变记录在表格中的位置,所以直接编译运行,供大家借鉴