I am having problems on inserting the controls TComboBox and TListBox in richviewedit. I'm using the following code:
var
listbox : TListBox;
begin
listbox : TListBox.create(self);
rve.insertcontrol('', listbox, rvvaBaseline);
end;
When I execute it, a exception is raised, "Control has no parent window". I tried set a parent, but the error continues.
Problem inserting TComboBox and TListBox in richviewedit
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Did you register the 'TComboBox'-class before inserting using 'RegisterClasses'?
You set the owner of the 'TListBox' to 'self'. Maybe it is better to typecast nihil to a 'TComponent'.
In C++ it look like this:
Good luck!
You set the owner of the 'TListBox' to 'self'. Maybe it is better to typecast nihil to a 'TComponent'.
In C++ it look like this:
Code: Select all
Call this once:
TComponentClass Classes[1] = { __classid(TComboBox };
RegisterClasses(Classes, 0);
Add the following lines into the 'OnClick'-event from a 'TButton':
TComboBox *cmbbx = new TComboBox((TComponent*)NULL);
cmbbx->Style = csDropDownList;
cmbbx->Font->Name = "Arial";
cmbbx->Font->Size = 8;
cmbbx->Font->Color = clBlack;
cmbbx->OnChange = OnChangeComponents;
if(RichViewEdit->InsertControl(aControlInfo, cmbbx, rvvaBaseline))
{
RichViewEdit->SetCurrentItemExtraIntProperty(rvepResizable, 1, true);
cmbbx->Items->Clear();
cmbbx->Items->Add("Option 1");
cmbbx->Items->Add("Option 2");
cmbbx->Items->Add("Option 3");
cmbbx->ItemIndex = 0;
RichViewEdit->Format();
RichViewEdit->SelectControl(cmbbx);
}