How do I erase a StringShape?

I’m using StringShape to put vertical labels in my app and that works fine, but how do I erase that StringShape?

The text for the StringShape comes from a TextField the user inputs, so I need to be able to erase the StringShape if the user changes the text, but I’m completely lost in how to do that.

I’ve been banging my head on this for hours and decided I’d better ask for help.

Jay

PS - I’ve played with StringShape and DrawRotatedTextMBS() but the problem exists with both.

How are you putting vertical labels in your app? What’s the code?

If you’re drawing to a Backdrop picture those persist. You’d need to erase the Backdrop before drawing the new, changed text. Or use a Paint event for drawing which can give a fresh slate each time.

The following code is in the Paint event of a ContainerControl:

VerticalLabelShapes(x) = new StringShape VerticalLabelShapes(x).Text = txt1Bit(x).text VerticalLabelShapes(x).TextFont = "Arial" VerticalLabelShapes(x).TextSize = 12 VerticalLabelShapes(x).Rotation = 4.71239 VerticalLabelShapes(x).X = 160 VerticalLabelShapes(x).Y = 50 g.DrawObject( VerticalLabelShapes(x) )

Jay

OK, so when the text changes you need to tell the ContainerControl to redraw. Add a TextChange event to txt1Bit and in there call this (where MyContainerControl is your container name)

MyContainerControl.Invalidate

Sounds easy, but my ContainerControl doesn’t seem to have an Invalidate option. Could be because I’m a “little” out of date using RealStudio 2011 r4? (I’m trapped there because of a 3rd-party control.)

Jay

What happens if you try to compile with Invalidate?

It says, “This method or property does not exist.”

Jay

Then do your drawing and invalidating in a canvas that is on the ContainerControl.

Invalidaterect or refreshrect the window in the area where the container exists?
dont use a container and just do it on the window directly?

In terms of how do you erase the text, you need to change or stop drawing the stringshape in the paint event.
Either set the text to “” or wrap the drawobject code in an ‘if’

Workaround: I threw a Canvas up in the ContainerControl and am doing my drawing/Invalidating on that.

Jay

(D’oh! Saw Beatrix make that suggestion as I was typing! Thanks!)

[quote=239496:@Jay Jennings]Sounds easy, but my ContainerControl doesn’t seem to have an Invalidate option. Could be because I’m a “little” out of date using RealStudio 2011 r4? (I’m trapped there because of a 3rd-party control.)
[/quote]

Refresh was available. But if you have already refactored with Canvas, it’s alright.

Yeah, I tried ContainerControl.Refresh but it gave me the same error message (not available). But since the Canvas trick worked, I’m good. :wink: Thanks!

Jay