-
Formattable Textbox
Hi All,
I need to create a textbox control that can have other objects embedded into it (Ie. Images). These objects need to be inserted into the flow of text. I can't see how to do it with a control inherited from a text box control. I also need to do text formatting, bulleting, TABS, numbering and paragraph styles.
Is it possible to inherit from TextBoxBase?
Thanks in advance.
Alan Liddle
-
A TextBox can't contain other Objects. Panels are the only Objects that can contain other Objects. Well, I suppose I could be wrong but at least that's how I understand it. :)
The only way I can think of this is to use a Panel. You'll have to actually draw the text using e.Graphics.DrawString in the Panels Paint event though.
-
That is a slite understatement..... Forms, Groupboxes, Toolbars and some other objects can contain other objects. There is also a possability to implement the IContainer interface for a Home-made control to create container features.
-
Hmm. Yeah. It's late, I just don't know what I type sometimes.. :o
-
Hehe, I know the feeling..... It's morning here and I just had my morning coffee, so I'm still alert.... :D
-
Also a richtextbox can hold images and things of that nature.
-
No kiddin? I didn't know that, LOL.
-
Can a RichTextBox really contain images? Can they contain other objects?
Alan
-
Yes. RTF is pretty much the same format that WORD uses. Although I'm not sure how you do tables. Images are no problem, you can use the RichTextBox's Paste method.
Yup I just tested tables too. Although I'm not sure the RTF code to make one, but you can copy one in so they can contain it.
-
Is it possible, when writing in a richtextbox, to be able to select an image using a filedialog and have it inserted into the text where the cursor is without cutting and pasting? (a sort of insert clipart)
-
Probably not, but you do the cutting and pasting in the code so the user doesn't see or do that part. You can also reset the clipboard with what it had before so they don't lose their own things they had in there.