Page 1 of 1

How to focus on the speciefied inserted item

Posted: Mon Jun 30, 2008 2:01 pm
by wray
Please give me ahint how to focus programatically on the specified item added.

For example i add a Text Edit like this:

TspSkinEdit * edit = new TspSkinEdit(this);
RichView1->AddControlEx("",edit,-1,rvvaBaseline);
RichView1->Format();

int ItemNo = RichView1->ItemCount-1;

I got the item number, how can i focus in the added Text Edit ?

Thank you

P.S. I tried RichView1->RVData->FocusedItemNo = ItemNo; but does not focus...

Posted: Mon Jun 30, 2008 2:24 pm
by wray
Done.

If you need it in the same function:

ActiveControl = edit;

if not, just retrieve the pointer and asign it to ActiveControl.

Sorry to bother you... :)

Posted: Mon Jun 30, 2008 6:25 pm
by Sergey Tkachenko
The simplest way is to call edit->SetFocus() after this code.

(If you know item index, check if this item really contains a control (RichView1->GetItemStyle(ItemNo)==rvsComponent, then get this control (RichView->GetControlInfo), and call SetFocus for the retrieved control. But if you already has it assigned to the "edit" variable, it is not necessary)