Board index » cppbuilder » GroupBox Question

GroupBox Question

I have a GroupBox with several edit controls. I am trying to access the
Edit->Text property but can't seem to get at it.

I've tried  

GroupBox1->Controls[0]->Text - get error that Text is not accessible.

tried

TControl *CC;
CC = GroupBox1->Controls[0];
CC->Text = "";   ------ get same error.

how can I read/write the text in the Edit control?

Thanx,
Vic Baron

 

Re:GroupBox Question


The Controls[] property returns a TControl*, of which the Text property is
protected (thus the errors).  You need a TEdit* instead, so you should cast
from one to the other.

You can do this one of two ways (I prefer method 1):

Method 1:

TEdit *edit = dynamic_cast<TEdit*>(GroupBox1->Controls[0]);
if(edit)
    edit->Text

Method 2:

((TEdit*)GroupBox1->Controls[0])->Text

Gambit

"Victor G. Baron" <vgba...@compuserve.com> wrote in message
news:pAFGOKibPp9yOVluHjD9pMar=pYF@4ax.com...

Quote
> I have a GroupBox with several edit controls. I am trying to access the
> Edit->Text property but can't seem to get at it.

> I've tried

> GroupBox1->Controls[0]->Text - get error that Text is not accessible.

> tried

> TControl *CC;
> CC = GroupBox1->Controls[0];
> CC->Text = "";   ------ get same error.

> how can I read/write the text in the Edit control?

> Thanx,
> Vic Baron

Re:GroupBox Question


Thank you very much - that's what I suspected but I'm not up to speed on 'casts'
and wasn't quite sure how to do it.

Appreciate the help,

Vic

Quote
On Wed, 1 Dec 1999 21:25:03 -0800, "Remy Lebeau" <gambi...@gte.net> wrote:
>The Controls[] property returns a TControl*, of which the Text property is
>protected (thus the errors).  You need a TEdit* instead, so you should cast
>from one to the other.

>You can do this one of two ways (I prefer method 1):

>Method 1:

>TEdit *edit = dynamic_cast<TEdit*>(GroupBox1->Controls[0]);
>if(edit)
>    edit->Text

>Method 2:

>((TEdit*)GroupBox1->Controls[0])->Text

>Gambit

Other Threads