Fábio Matte Posted December 14, 2021 Share Posted December 14, 2021 (edited) Hi, I'm trying to put the Filtering.Editor option on dynamically created columns in a UniDBGrid, but it doesn't work at all, in all the ways I try, I get the message "Argument out of range" when running. Here is the code I used to apply the filter: dbGridSQL_Resultado.Columns.Clear; if optControl = 1 then begin with dbGridSQL_Resultado do begin DataSource := dsFDMemTable; Columns.Items[0].Filtering.Editor := TUniEdit(Self.FindComponent('UniEdit1').Name); Columns.Items[0].Filtering.Enabled := True; end; end; Image Error: Edited December 16, 2021 by Fábio Matte Quote Link to comment Share on other sites More sharing options...
picyka Posted December 14, 2021 Share Posted December 14, 2021 3 minutes ago, Fábio Matte said: Oi, estou tentando colocar a opção Filtragem.Editor em colunas criadas dinamicamente em um UniDBGrid, mas não funciona de jeito nenhum, de todas as maneiras que tento, recebo a mensagem "Argumento fora do alcance" ao executar. Aqui está o código que usei para aplicar o filtro: dbGridSQL_Resultado.Columns.Clear; if optControl = 1 then begin with dbGridSQL_Resultado do begin DataSource := dsFDMemTable; Columns.Items[0].Filtering.Editor := TUniEdit(Self.FindComponent('UniEdit1').Name); Columns.Items[0].Filtering.Enabled := True; end; end; Erro de imagem: Self.FGrid.Columns[i].Filtering.Editor Quote Link to comment Share on other sites More sharing options...
Fábio Matte Posted December 14, 2021 Author Share Posted December 14, 2021 1 minute ago, picyka said: Self.FGrid.Columns[i].Filtering.Editor But at what point would I put this? Because I would need to pass in my column 0, a filter, according to what I type in UniEdit. FGrid.Columns.Items[0].Filtering.Editor := UniEdit; But that doesn't work, it gives the same error returned in the error image I posted. Quote Link to comment Share on other sites More sharing options...
picyka Posted December 14, 2021 Share Posted December 14, 2021 3 minutes ago, Fábio Matte said: Mas em que ponto eu colocaria isso? Porque eu precisaria passar na minha coluna 0, um filtro, de acordo com o que eu digito no UniEdit. FGrid.Columns.Items[0]. Filtragem.Editor := UniEdit; Mas isso não funciona, dá o mesmo erro retornado na imagem de erro que postei. dbGridSQL_Resultado.Columns[0].Filtering.Editor := UniEdit; Quote Link to comment Share on other sites More sharing options...
Fábio Matte Posted December 14, 2021 Author Share Posted December 14, 2021 3 minutes ago, picyka said: dbGridSQL_Resultado.Columns[0].Filtering.Editor := UniEdit; In fact, it's the way you suggested it to me, but I'm still wrong. I do this by clicking on a Button, TUniButton. Quote Link to comment Share on other sites More sharing options...
picyka Posted December 14, 2021 Share Posted December 14, 2021 15 minutes ago, Fábio Matte said: In fact, it's the way you suggested it to me, but I'm still wrong. I do this by clicking on a Button, TUniButton. In the format I sent also the error? why are different codes. Quote Link to comment Share on other sites More sharing options...
picyka Posted December 14, 2021 Share Posted December 14, 2021 for var i : Integer := 0 to Self.FGrid.Columns.Count - 1 do begin if (Self.FGrid.Columns[i].Filtering.Enabled) and (Self.FGrid.Columns[i].Filtering.Editor <> nil) then begin lUpdate := True; if Self.FGrid.Columns[i].Filtering.Editor is TUniEdit then TUniEdit(Self.FGrid.Columns[i].Filtering.Editor).Clear else if Self.FGrid.Columns[i].Filtering.Editor is TUniCheckComboBox then TUniCheckComboBox(Self.FGrid.Columns[i].Filtering.Editor).ClearSelection else if Self.FGrid.Columns[i].Filtering.Editor is TUniDateTimePicker then TUniDateTimePicker(Self.FGrid.Columns[i].Filtering.Editor).Text := ''; end; end; I have something similar. Quote Link to comment Share on other sites More sharing options...
Fábio Matte Posted December 16, 2021 Author Share Posted December 16, 2021 On 12/14/2021 at 3:18 PM, picyka said: for var i : Integer := 0 to Self.FGrid.Columns.Count - 1 do begin if (Self.FGrid.Columns[i].Filtering.Enabled) and (Self.FGrid.Columns[i].Filtering.Editor <> nil) then begin lUpdate := True; if Self.FGrid.Columns[i].Filtering.Editor is TUniEdit then TUniEdit(Self.FGrid.Columns[i].Filtering.Editor).Clear else if Self.FGrid.Columns[i].Filtering.Editor is TUniCheckComboBox then TUniCheckComboBox(Self.FGrid.Columns[i].Filtering.Editor).ClearSelection else if Self.FGrid.Columns[i].Filtering.Editor is TUniDateTimePicker then TUniDateTimePicker(Self.FGrid.Columns[i].Filtering.Editor).Text := ''; end; end; I have something similar. Thank you friend, it worked perfect, it came out better than I expected. 1 Quote Link to comment Share on other sites More sharing options...
Fábio Matte Posted December 16, 2021 Author Share Posted December 16, 2021 Just now, Fábio Matte said: Thank you friend, it worked perfect, it came out better than I expected. Code: for i := 0 to Self.dbGridSQL_Resultado.Columns.Count - 1 do begin if (Self.dbGridSQL_Resultado.Columns[i].Filtering.Enabled) and (Self.dbGridSQL_Resultado.Columns[i].Filtering.Editor <> nil) then begin if Self.dbGridSQL_Resultado.Columns[i].Filtering.Editor is TUniEdit then TUniEdit(Self.dbGridSQL_Resultado.Columns[i].Filtering.Editor).Clear else if Self.dbGridSQL_Resultado.Columns[i].Filtering.Editor is TUniCheckComboBox then TUniCheckComboBox(Self.dbGridSQL_Resultado.Columns[i].Filtering.Editor).ClearSelection else if Self.dbGridSQL_Resultado.Columns[i].Filtering.Editor is TUniDateTimePicker then TUniDateTimePicker(Self.dbGridSQL_Resultado.Columns[i].Filtering.Editor).Text := ''; end; 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.