Forum > LCL
add picklist to tvaluelisteditor value
babycode:
Good afternoon, I'm loading boolean fields from my database into TValueListEditor to manipulate some system permissions. Using the code:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TfrmUser.LoadPermissions;var i: Integer;begin vlePermissions.Strings.BeginUpdate; try vlePermissions.Strings.Clear; for i := 0 to dsProfiles.DataSet.FieldCount - 1 do begin if dsProfiles.DataSet.Fields[i].DataType = ftBoolean then begin vlePermissoes.InsertRow(dsProfiles.DataSet.Fields[i].FieldName, BoolToStr(dsProfiles.DataSet.Fields[i].AsBoolean, True), True); with vlePermissions.ItemProps[dsProfiles.DataSet.Fields[i].FieldName] do begin EditStyle := esPickList; ReadOnly := True; PickList.Add('True'); PickList.Add('False'); end; end; end; finally vlePermissions.Strings.EndUpdate; end;end;
The compiler displays this warning
uuser.pas(1163,76) Note: Call to subroutine "operator :=(const source:ShortString):Variant;" marked as inline is not inlined
When I try to call the procedure to load the data it shows an exception and terminates.
To save the change in the bank I am using:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TfrmUser.vlePermissionsSetEditText(Sender: TObject; ACol, ARow: Integer; const Value: string);var Field: TField;begin if dsProfiles.DataSet.State in [dsEdit, dsInsert] then begin Field := dsProfiles.DataSet.FieldByName(vlePermissions.Keys[ARow]); if Assigned(Field) and (Field.DataType = ftBoolean) then Field.AsBoolean := StrToBoolDef(Value, True); end;end;
Has anyone done something similar and can give me a solution?
dseligo:
--- Quote from: babycode on May 16, 2024, 09:39:24 pm ---The compiler displays this warning
uuser.pas(1163,76) Note: Call to subroutine "operator :=(const source:ShortString):Variant;" marked as inline is not inlined
--- End quote ---
This is not a warning, it's a note, and it has nothing to do with your problem.
What exception do you get?
Can you make small complete demo (that can be compiled) that shows your problem? In case nobody picks error in snippets you posted.
babycode:
It displays this error when calling the data loading procedure. I'm going to build a mini demo, but I'm using postgre database, so you'll need it.
babycode:
A little demonstration of what I'm trying to do. When clicking the load button, the data from the permissions table must be loaded into the valuelisteditor, and the user can change the value of the fields. But I wanted to add a pick list so that the user could only select true or false.
jamie:
its your xxx.Strings.BeginUpdate and xxx.Strings.EndUpdate.
You are locking your strings.
use the outer update..
MyValueListEditor.BeginUpdate;
.....
MyValueListEditor.EndUpdate.
Navigation
[0] Message Index
[#] Next page