picyka Posted July 23, 2021 Share Posted July 23, 2021 Hi, I can do a type cast on one to improve this code class procedure TConfigureRequired.Configure(List: TDictionary<String, TComponent>; Dataset: TAureLiusDataSet); begin for var lControle in List do begin if Dataset.FieldByName(lControle.Key).Required then begin if lControle.Value is TUniDBEdit then TUniDBEdit(lControle.Value).FieldLabel := TUniDBEdit(lControle.Value).FieldLabel + '<font color="Red"> *</font>' else if lControle.Value is TUniDBComboBoxObject then TUniDBComboBoxObject(lControle.Value).FieldLabel := TUniDBComboBoxObject(lControle.Value).FieldLabel + '<font color="Red"> *</font>' else if lControle.Value is TUniDBDateTimePicker then TUniDBDateTimePicker(lControle.Value).FieldLabel := TUniDBEdit(lControle.Value).FieldLabel + '<font color="Red"> *</font>' else if lControle.Value is TUniDBMemo then TUniDBMemo(lControle.Value).FieldLabel := TUniDBMemo(lControle.Value).FieldLabel + '<font color="Red"> *</font>' else if lControle.Value is TUniDBComboBoxValue then TUniDBComboBoxValue(lControle.Value).FieldLabel := TUniDBComboBoxValue(lControle.Value).FieldLabel + '<font color="Red"> *</font>' else if lControle.Value is TUniDBFormattedNumberEdit then TUniDBFormattedNumberEdit(lControle.Value).FieldLabel := TUniDBFormattedNumberEdit(lControle.Value).FieldLabel + '<font color="Red"> *</font>'; end; end; end; Quote Link to comment Share on other sites More sharing options...
picyka Posted July 23, 2021 Author Share Posted July 23, 2021 Dois minutos atrás, Picyka disse: Oi, eu posso fazer um tipo de elenco em um para melhorar este código class procedure TConfigureRequired.Configure(List: TDictionary<String, TComponent>; Dataset: TAureLiusDataSet); begin for var lControle in List do begin if Dataset.FieldByName(lControle.Key).Required then begin if lControle.Value is TUniDBEdit then TUniDBEdit(lControle.Value).FieldLabel := TUniDBEdit(lControle.Value).FieldLabel + '<font color="Red"> *</font>' else if lControle.Value is TUniDBComboBoxObject then TUniDBComboBoxObject(lControle.Value).FieldLabel := TUniDBComboBoxObject(lControle.Value).FieldLabel + '<font color="Red"> *</font>' else if lControle.Value is TUniDBDateTimePicker then TUniDBDateTimePicker(lControle.Value).FieldLabel := TUniDBEdit(lControle.Value).FieldLabel + '<font color="Red"> *</font>' else if lControle.Value is TUniDBMemo then TUniDBMemo(lControle.Value).FieldLabel := TUniDBMemo(lControle.Value).FieldLabel + '<font color="Red"> *</font>' else if lControle.Value is TUniDBComboBoxValue then TUniDBComboBoxValue(lControle.Value).FieldLabel := TUniDBComboBoxValue(lControle.Value).FieldLabel + '<font color="Red"> *</font>' else if lControle.Value is TUniDBFormattedNumberEdit then TUniDBFormattedNumberEdit(lControle.Value).FieldLabel := TUniDBFormattedNumberEdit(lControle.Value).FieldLabel + '<font color="Red"> *</font>'; end; end; end; Eu não poderia descobrir onde FieldLabel nasceu, talvez a solução está lá Quote Link to comment Share on other sites More sharing options...
Hayri ASLAN Posted July 24, 2021 Share Posted July 24, 2021 5 hours ago, picyka said: Hi, I can do a type cast on one to improve this code class procedure TConfigureRequired.Configure(List: TDictionary<String, TComponent>; Dataset: TAureLiusDataSet); begin for var lControle in List do begin if Dataset.FieldByName(lControle.Key).Required then begin if lControle.Value is TUniDBEdit then TUniDBEdit(lControle.Value).FieldLabel := TUniDBEdit(lControle.Value).FieldLabel + '<font color="Red"> *</font>' else if lControle.Value is TUniDBComboBoxObject then TUniDBComboBoxObject(lControle.Value).FieldLabel := TUniDBComboBoxObject(lControle.Value).FieldLabel + '<font color="Red"> *</font>' else if lControle.Value is TUniDBDateTimePicker then TUniDBDateTimePicker(lControle.Value).FieldLabel := TUniDBEdit(lControle.Value).FieldLabel + '<font color="Red"> *</font>' else if lControle.Value is TUniDBMemo then TUniDBMemo(lControle.Value).FieldLabel := TUniDBMemo(lControle.Value).FieldLabel + '<font color="Red"> *</font>' else if lControle.Value is TUniDBComboBoxValue then TUniDBComboBoxValue(lControle.Value).FieldLabel := TUniDBComboBoxValue(lControle.Value).FieldLabel + '<font color="Red"> *</font>' else if lControle.Value is TUniDBFormattedNumberEdit then TUniDBFormattedNumberEdit(lControle.Value).FieldLabel := TUniDBFormattedNumberEdit(lControle.Value).FieldLabel + '<font color="Red"> *</font>'; end; end; end; Hi Can you try below code? type THackFormControl = class(TUniFormControl); THackFormControl(lControle.Value).FieldLabel := THackFormControl(lControle.Value).FieldLabel + '<font color="Red"> *</font>'; Quote Link to comment Share on other sites More sharing options...
picyka Posted July 24, 2021 Author Share Posted July 24, 2021 7 hours ago, Hayri ASLAN said: Hi Can you try below code? type THackFormControl = class(TUniFormControl); THackFormControl(lControle.Value).FieldLabel := THackFormControl(lControle.Value).FieldLabel + '<font color="Red"> *</font>'; Perfect thank you. 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.