Adding A TSRVComboBox

ScaleRichView support and discussion (TRichView add-on for WYSIWYG editing)
Post Reply
ntavendale
Posts: 16
Joined: Sun Oct 10, 2010 6:05 pm

Adding A TSRVComboBox

Post 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?
proxy3d
ScaleRichView Developer
Posts: 307
Joined: Mon Aug 07, 2006 9:37 am

Post 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; 
proxy3d
ScaleRichView Developer
Posts: 307
Joined: Mon Aug 07, 2006 9:37 am

Post 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;
Post Reply