Jump to content

UniSegmentedButton


picyka

Recommended Posts

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniListButtom.Items.Add;
  UniListButtom.Items[UniListButtom.Items.Count-1].ButtonId := UniListButtom.Items.Count + 1;
  UniListButtom.Items[UniListButtom.Items.Count-1].ImageIndex := 0;
  UniListButtom.Items[UniListButtom.Items.Count-1].Caption :='teste0';

  UniListButtom.Items.Add;
  UniListButtom.Items[UniListButtom.Items.Count-1].ButtonId := UniListButtom.Items.Count + 1;
  UniListButtom.Items[UniListButtom.Items.Count-1].ImageIndex := 0;
  UniListButtom.Items[UniListButtom.Items.Count-1].Caption :='teste1';
end;

Another detail that the inclusion of items at runtime does not work

Link to comment
Share on other sites

7 hours ago, picyka said:

and they must be aligned in the center

Hello,

Use container, for example

UniContainerPanel 1-> Align = alTop, AlignmentControl = uniAlignmentClient, Layout = hbox, LayouAttribs -> Align = middle, Pack = center

UniSegmentedButton1 -> Align = alNone  

image.png.c044aa59fff5263ec2224bcc8e9a11b6.png

Result:

image.thumb.png.eae5d8431ea30a06643962749ea61637.png

Link to comment
Share on other sites

No dia 9/12/2022 às 17:54, picyka disse:
procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniListButtom.Items.Add;
  UniListButtom.Items[UniListButtom.Items.Count-1].ButtonId := UniListButtom.Items.Count + 1;
  UniListButtom.Items[UniListButtom.Items.Count-1].ImageIndex := 0;
  UniListButtom.Items[UniListButtom.Items.Count-1].Caption :='teste0';

  UniListButtom.Items.Add;
  UniListButtom.Items[UniListButtom.Items.Count-1].ButtonId := UniListButtom.Items.Count + 1;
  UniListButtom.Items[UniListButtom.Items.Count-1].ImageIndex := 0;
  UniListButtom.Items[UniListButtom.Items.Count-1].Caption :='teste1';
end;

Outro detalhe que a inclusão de itens em tempo de execução não funciona

And how to do the inclusion and exclusion?

Link to comment
Share on other sites

15 hours ago, picyka said:

I need to add/remove items to a UniSegmentedButton at runtime.

Hello,

Try this approach:

procedure TMainForm.UniButton1Click(Sender: TObject);
var
  btnItem: TUniButtonItem;
begin
  // Add
  with UniSegmentedButton1 do
  begin
    btnItem := TUniButtonItem(Items.Add);
    JSInterface.JSCall('removeAll', []);
    Items.InsertButtons(JSControl, Images, False);
    // Set the caption here
    btnItem.Caption := 'Button' + Items.Count.ToString();
  end;

end;

 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...