Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cast Text from DrawObjects

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Cast Text from DrawObjects

    From the Help Guide: Lets say this is in Indi_001:
    Text myText;
    protected override void OnBarUpdate()
    {
    if(CurrentBar==50) myText=Draw.Text(this,"tag","test",0,High[0]);
    if(myText !=null ) Print(myText.Anchor.DrawnOnBar);// drawn on bar 50
    }
    .. then in Indi_002 I want to retrieve that text. I can get it with a foreach loop looking at all the tags for "tag"
    But I know the tag, so I try to read it directly with DrawObjects["tag"] and I can get it semi OK
    It shows me the Tag.
    But when I try to show DisplayName I get all sorts of errors for bad cast etc. Ive tried all sorts of combinations to get this, and even one that looks right and compiles. But it gives a run-time error of no instance assigned etc.
    I need to see DrawObjects["tag"].DisplayName and then Time.
    "missing a using or cast.??.."
    Last edited by kenz987; 04-11-2025, 11:30 AM.

    #2
    Hello kenz987,

    Thank you for your post.

    If you want to get the actual text you would need to use DisplayText, not DisplayName. Please see this forum post that discusses:



    Please let us know if you have any further questions.

    Comment


      #3
      Thanks Gaby, But thats no help. I want to avoid a loop. My Count gets very large. I have the tag, how do I get the data with DrawObjects["tag"] . . ??

      Comment


        #4
        The same concept still applies, you would access it from the DrawObjects collection via the tag.



        Code:
        if (DrawObjects["someTag"] != null && DrawObjects["someTag"] is DrawingTools.Text)
        {
        DrawingTools.Text myDrawText = DrawObjects["someTag"] as DrawingTools.Text;
        Print(myDrawText.DisplayText);
        }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        63 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        90 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        47 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        105 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        63 views
        0 likes
        Last Post PaulMohn  
        Working...
        X