# C++ 101 question - ITextControl

**URL:** <https://iplug2.discourse.group/t/c-101-question-itextcontrol/519>\
**Category:** Uncategorized\
**Created:** [5 December 2021 20:32 UTC](https://iplug2.discourse.group/t/c-101-question-itextcontrol/519 "2021-12-05T20:32:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RexMartin2](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@RexMartin2](https://iplug2.discourse.group/u/RexMartin2)\
**Post date:** [5 December 2021 20:32 UTC](https://iplug2.discourse.group/t/c-101-question-itextcontrol/519/1 "2021-12-05T20:32:49Z")

</div>

SetStr(const char\* str) is a public member function of ITextControl which inherits from IControl.

We instantiate an ITextControl in the mLayoutFunc section of iPlug like this:

`pGraphics->AttachControl(new ITextControl(IRECT(240, 50, 250, 60), "Start Text"), kTextTag);`

which creates a new instance of an ITextControl referenced by the kTextTag.

So how come I can’t access/update the text string in this control later on by doing this:

`GetUI()->GetControlWithTag(kTextTag)->SetStr("New Text");`

compiler says the control has no member function “SetStr()”. Why is that?

---

<div class="post-metadata">

**Author:** ![olilarkin](https://yyz2.discourse-cdn.com/free1/user_avatar/iplug2.discourse.group/olilarkin/32/2_2.png) [@olilarkin](https://iplug2.discourse.group/u/olilarkin)\
**Post date:** [5 December 2021 23:03 UTC](https://iplug2.discourse.group/t/c-101-question-itextcontrol/519/2 "2021-12-05T23:03:41Z")

</div>

GetControlWithTag() returns an IControl\* . You can dynamic cast that to an ITextControl\*. There is a helper you can use. E.g

`GetControlWithTag(Tag)->As<ITextControl>()->SetStr(“blah”)`

---

<div class="post-metadata">

**Author:** ![RexMartin2](https://avatars.discourse-cdn.com/v4/letter/r/da6949/32.png) [@RexMartin2](https://iplug2.discourse.group/u/RexMartin2)\
**Post date:** [6 December 2021 20:23 UTC](https://iplug2.discourse.group/t/c-101-question-itextcontrol/519/3 "2021-12-06T20:23:11Z")

</div>

Excellent! Thank you for the lesson and the tip. Now that you’ve pointed that out I see that dynamic cast helper used a lot in the IPlugControls example (which I didn’t understand previously).
