472,958 Members | 2,035 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

RTF content in Context Menu

I have a requirement- need to display RTF content in context menu. I
am able to host a rich textbox in a contextmenu strip using
ToolStripControlHost class. But assigning some RTF content to the
containing rich textbox control does not display in actual RTF
format- it just dislpays as plain text. Here's the code am using:
//Custom richtextbox to handle bg color in readonly mode
public class MyRichTextBox : RichTextBox
{
public MyRichTextBox()
{
}

public new bool ReadOnly
{
get
{
return base.ReadOnly;
}
set
{
if (value == true)
{
this.BackColor = Color.White;
}

base.ReadOnly = value;
}
}

}

----------------------------------------------------------------
public Form1()
{
InitializeComponent();

m_cmenu.Items.Add(new ToolStripMenuItem("Edit"));
m_cmenu.Items.Add(new ToolStripSeparator());

MyRichTextBox m_richTextBox = new MyRichTextBox();
m_richTextBox.BorderStyle =
System.Windows.Forms.BorderStyle.None;
m_richTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
m_richTextBox.ReadOnly = true;
m_richTextBox.ScrollBars =
System.Windows.Forms.RichTextBoxScrollBars.None;

ToolHost textItem = new ToolHost(m_richTextBox);
//Assign sample RTF content.
m_richTextBox.Rtf = @"{\rtf1\fbidis\ansi
\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss \fprq2\fcharset0
Arial;}{\f1\fnil\fcharset0 Microsoft Sans Serif;}}
\viewkind4\uc1\pard\ltrpar\sa200\sl276\slmult1\f0\ fs28 This is\fs22
\i some\i0 \ul Rich\ulnone \b text\b0\par
\pard\ltrpar\f1\fs17\par }";

m_cmenu.Items.Add(textItem);
this.ContextMenuStrip = m_cmenu;//Assign contextmenu for
Form

}
Jun 27 '08 #1
0 1204

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mohit Gupta | last post by:
Hi all, Lately I have been working on an application in VB .net CF for Pocket PC device. I have a small question about Context Menu. When I try to close the window after context menu is poped...
5
by: Dean L. Howen | last post by:
Dear friends, Could we determine when context menu should appear?
8
by: Dennis C. Drumm | last post by:
Is there a way to modify the standard context menu shown when someone right clicks in a windows text box and that would work for all open windows applications? The standard context menu for...
0
by: VP | last post by:
G'day folks, well i am attempting to get an understanding on how to create the menuitems in a context menu on the fly. So far I have managed to actually achieve the menu items being created for...
5
by: lgbjr | last post by:
Hello All, I have several Pictureboxes (linked to an AccessDB) on a VB.NET form. I would like to use a context menu to allow the user to open the picture in their default picture viewer or...
1
by: goRide | last post by:
Hi, I'm looking of a way (preferred - a ready class or dll) to customize the context menu. many application has more controls inside the context menu (like textbox, sliders, checkbox, panel...
2
by: MCM | last post by:
I'm working on a plotting control. The plotting control will have a context menu with basic commands for "scaling", "zooming", etc. Is there a way that, from the parent form, I can add more...
7
by: Terry | last post by:
Hi again folks. I have a couple of issues now. I am not sure why I can't get my menu to overlap the content area. I tried using z-index. The effect I want occurs in Firefox but not IE. ...
19
by: BibhuAshish | last post by:
Hello, I have created a context menu in mozilla by using following code: function nrc(e) { var contextMenu; document.oncontextmenu = function (evt) { var srcElement; if (evt &&...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.