How to focus on the speciefied inserted item

General TRichView support forum. Please post your questions here
Post Reply
wray
Posts: 38
Joined: Thu Feb 14, 2008 8:36 pm
Location: Romania

How to focus on the speciefied inserted item

Post 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...
wray
Posts: 38
Joined: Thu Feb 14, 2008 8:36 pm
Location: Romania

Post 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... :)
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

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