2010-10-23 79 views
3

我需要過濾一個TClientDataset,實際上我使用這段代碼。是否可以使用不敏感的情況過濾TClientDataset?

if Value<>'' then 
    begin 
     ClientDataSet1.DisableControls; 
     try 
     ClientDataSet1.Filtered := False; 
     ClientDataSet1.Filter := 'Value LIKE ' + QuotedStr('%'+Value+'%'); 
     ClientDataSet1.Filtered := True; 
     finally 
     ClientDataSet1.EnableControls; 
     end; 
    end; 

但過濾器工作在區分大小寫模式下,是否可以過濾記錄忽略大小寫?

回答

13

您必須使用FilterOptions屬性和foCaseInsensitive值。

ClientDataSet1.DisableControls; 
    try 
    ClientDataSet1.Filtered := False; 
    ClientDataSet1.FilterOptions := [foCaseInsensitive]; 
    ClientDataSet1.Filter := 'Value LIKE ' + QuotedStr('%'+Value+'%'); 
    ClientDataSet1.Filtered := True; 
    finally 
    ClientDataSet1.EnableControls; 
    end; 
相關問題