Page 1 of 1

Adding A TSRVComboBox

Posted: Tue Oct 12, 2010 3:53 am
by ntavendale
Usign the InsertControlsD2009 Demo for Scale Rich View I am trying to add a combo box using the code below:

Code: Select all

procedure TFInsertControls.ToolButton16Click(Sender: TObject);
var
  c : TSRVComboBox;
  ci: TCollectionItem;
begin
  c := TSRVComboBox.Create(nil);
  c.Parent := SRichViewEdit1.RichViewEdit;
  c.Color := clWhite;
  ci := c.Items.Add;
  ci.DisplayName := 'Left';
  ci := c.Items.Add;
  ci.DisplayName := 'Right';
  SRichViewEdit1.RichViewEdit.InsertControl('teste', c, rvvaMiddle);
end;
It adds OK but 'Left' and 'Right' do not show up when I open it.

Anyone know what I should be doing?

Also the ScaleRichView Help File doesn't seem to work. Is there an updated version anywhere?

Posted: Tue Oct 12, 2010 8:07 am
by proxy3d
Caption - the text element in the list for SRVCombobox
DisplayName - the text in the Object Inspector at design mode.

Code: Select all

procedure TFInsertControls.ToolButton16Click(Sender: TObject); 
var 
  c : TSRVComboBox; 
  ci: TCollectionItem; 
begin 
  c := TSRVComboBox.Create(nil); 
  c.Parent := SRichViewEdit1.RichViewEdit; 
  c.Color := clWhite; 
  ci := c.Items.Add; 
  TSRVCBoxItem(ci).Caption := 'Left';
  ci := c.Items.Add; 
  TSRVCBoxItem(ci).Caption := 'Right';
  SRichViewEdit1.RichViewEdit.InsertControl('teste', c, rvvaMiddle); 
end; 
or

Code: Select all

procedure TFInsertControls.ToolButton16Click(Sender: TObject); 
var 
  c : TSRVComboBox; 
  ci: TSRVCBoxItem; 
begin 
  c := TSRVComboBox.Create(nil); 
  c.Parent := SRichViewEdit1.RichViewEdit; 
  c.Color := clWhite; 
  ci := TSRVCBoxItem(c.Items.Add); 
  ci.Caption := 'Left';
  ci := TSRVCBoxItem(c.Items.Add); 
  ci.Caption := 'Right';
  SRichViewEdit1.RichViewEdit.InsertControl('teste', c, rvvaMiddle); 
end; 

Posted: Tue Oct 12, 2010 8:10 am
by proxy3d
I recommend using BeginUpdate and EndUpdate, if the elements greater than 3.

Code: Select all

  c.BeginUpdate;
  ci := c.Items.Add;
  ....
  c.EndUpdate;