|
|
I have written app, borrowing some code from this article ( http://www.codeproject.com/cs/miscctrl/MyExtRichTextBox.asp?df=100&forumid=229962&select=1556581&msg=1556581[^] ). I have controls being inserted at various locations throughout a document and everything looks great. I'm able to query the interface and iterate through each control in the document. Great.
Now, however, I have to be able to save the document to be reloaded at a later time in the same application. When I do this normally, I lose the control information.
So, how can I save the document so that when I reload it, my controls are still showing up in the richtextbox?
Any help is greatly appreciated.
Thanks,
Tony
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.
|
|
|
|
|
When I look at the rtf, each place a control should be I have this:
\objattph\'20
So, something is being saved. However, there are properties on each control that are unique for each control inserted. I need to persist this data.
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.
|
|
|
|
|
Hi!
What are you using to save/load the contents of the RTB?
I just tried pasting an OLE object into the RTB, then saving it via RichTextBox.SaveFile() . Re-loading it afterwards with RichTextBox.LoadFile() showed the object...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Well, I'm not using an OLE object (which is the most likely reason why this doesn't work), I'm using a control I created in VS 2003. I'm fairly certain that if I implement the correct interfaces in the control that it will save correctly. But, I wouldn't swear to it.
I've tried the save file, I've even tried streaming it straight to disk. The objects are there because I can (using IRichEditOle.GetObjectCount) get a correct count of objects, and actually get the objects back, cast them to the appropriate control and access their properties. This is all before saving though. Once saved, it seems that only a placeholder is saved, and not the object or it's data.
Any ideas on what ole interfaces need to be implemented? Any Examples would be appreciated as well. I can't seem to find a lot of information about this.
Thanks,
Tony
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.
|
|
|
|
|
Any help is appreciated.
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.
|
|
|
|
|
I have a listbox with a contextmenu. The contextmenu has items such as "add" and "move up" and "move down" and "delete".
But how do I get the listboxitem that were clicked and hence the 'object' for the actions? It's not the selected item on the listbox since I right clicked to get the contextmenu.
I have a feeling that this should be easy, but I just dont know how to do it.
|
|
|
|
|
iakob wrote: But how do I get the listboxitem that were clicked
They hide that information in the documentation[^]
led mike
|
|
|
|
|
Basically, you need to handle the MouseDown event on the listbox and select the item you clicked.
private void listBox1_MouseDown(object sender, MouseEventArgs e)
{
ListBox listBox = sender as ListBox;
if (e.Button == MouseButtons.Right)
{
int index = listBox.IndexFromPoint(e.X, e.Y);
if (index >= 0 && index < listBox.Items.Count)
{
listBox.SelectedIndex = index;
}
listBox.Refresh();
}
}
In your event handler for the the context menu item, you will need to test if there are any selected items and do the appropriate action. Something like this:
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
{
if (listBox1.SelectedItems.Count > 0)
{
MessageBox.Show(listBox1.SelectedItems[0].ToString());
}
else
{
MessageBox.Show("You didn't select an item!");
}
}
If you really want to, you would actually enable/disable context menu options in your MouseDown event handler based on an item being selected or the user right clicking in "white space".
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
Thank you both (though one was more impudent than the other .
I've browsed the documentation and googled the question without finding an answer. Guess I simply failed to spot that particular member. RTFM is simple enough, one should think.
But thanks again.
|
|
|
|
|
Hey, this is my problem: i select the last line after i added the new text, i change the color of the line, but then all the lines before becomes the first color inserted and not the color i added them before.
what's the problem and how can i fix it?
this is the code where i add the text in:
private void rtbAddText(String NewText, Color NewColor)
{
NewText += Environment.NewLine;
if (NewColor == null)
this.rtbConsole.Text = NewText;
else
{
int OldLength = rtbConsole.Text.Length;
this.rtbConsole.Text += NewText;
this.rtbConsole.Select(OldLength, NewText.Length);
this.rtbConsole.SelectionColor = NewColor;
}
}
Thanks... NaNg.
|
|
|
|
|
rather than using
this.rtbConsole.Text += NewText; you should use
this.rtbConsole.AppendText(NewText);
HTH
|
|
|
|
|
Thanks.... was looking for Add() function... (at start) :P
|
|
|
|
|
Hi,
Is it possible to load up a GridView where all rows are in edit mode?
Thanks
|
|
|
|
|
Is this an ASP.NET question?
led mike
|
|
|
|
|
|
I have never been able to figure this oneout, or find anything that reliably worked, either.
i am trying to develope an app that uses a richtextbox for input, and has all the options that wordpad does. Now, i realise i may not be able to pull off each and every trick, but there is one in particular that is driving me crazy. in wirdpad, say I have this sentance:
Bold and Italic are font styles.
Now, something i can do very easily is switch individual selections back and forth between one font style and another, so this would be easy:
Bold and Italic are font styles.
the problem is, if i want to do this:
Bold and Italic are font styles.
i get one or the other, basically whichever i selected last. here is the code i am using. rtb is the RichTextBox:
private void btnBold_Click(object sender, EventArgs e)<br />
{<br />
if (rtb.SelectionFont.Bold)<br />
rtb.SelectionFont = new Font(rtb.SelectionFont.FontFamily, rtb.SelectionFont.Size, FontStyle.Regular);<br />
else<br />
rtb.SelectionFont = new Font(rtb.SelectionFont.FontFamily, rtb.SelectionFont.Size, FontStyle.Bold);<br />
rtb.Select();<br />
}<br />
<br />
private void btnItal_Click(object sender, EventArgs e)<br />
{<br />
if (rtb.SelectionFont.Italic)<br />
rtb.SelectionFont = new Font(rtb.SelectionFont.FontFamily, rtb.SelectionFont.Size, FontStyle.Regular);<br />
else<br />
rtb.SelectionFont = new Font(rtb.SelectionFont.FontFamily, rtb.SelectionFont.Size, FontStyle.Italic);<br />
rtb.Select();<br />
}
I am using C# express and the 2.0 framework. Any ideas?
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
in each one u do not check if it's the other one.
if it is it resets the other one....
think about it.
|
|
|
|
|
Granted, that is true, but even if I just set it to italic or bold, like this:
private void btnBold_Click(object sender, EventArgs e)<br />
{<br />
rtb.SelectionFont = new Font(rtb.SelectionFont.FontFamily, rtb.SelectionFont.Size, FontStyle.Bold);<br />
rtb.Select();<br />
}<br />
<br />
private void btnItal_Click(object sender, EventArgs e)<br />
{<br />
rtb.SelectionFont = new Font(rtb.SelectionFont.FontFamily, rtb.SelectionFont.Size, FontStyle.Italic);<br />
rtb.Select();<br />
}
whatever the new fontstyle is, it overrides the existing one. So for example, i have this:
Short sentance
and i highlight like this:
Short se ntance
then try setting it to iatlics, rather than getting this:
Short sentance
i get this:
Short sentance
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
Try something like this -->
this.richTextBox1.Text = "This is a test";
this.richTextBox1.SelectionStart = 0;
this.richTextBox1.SelectionLength = 7;
System.Drawing.Font currentFont = richTextBox1.SelectionFont;
System.Drawing.FontStyle newFontStyle;
newFontStyle = FontStyle.Bold;
richTextBox1.SelectionFont = new System.Drawing.Font(currentFont.FontFamily, currentFont.Size, newFontStyle);
currentFont = richTextBox1.SelectionFont;
this.richTextBox1.SelectionStart = 5;
this.richTextBox1.SelectionLength = 3;
newFontStyle = FontStyle.Italic | FontStyle.Bold;
richTextBox1.SelectionFont = new System.Drawing.Font(currentFont.FontFamily, currentFont.Size, newFontStyle);
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.
|
|
|
|
|
Awesome! That certainly got me going in the right direction. Its almost emberassing how long i have tried to get this working....
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
Glad to help.
It's only when you look at an ant through a magnifying glass on a sunny day that you realise how often they burst into flames.
|
|
|
|
|
i have a dataview it has several rows
how can i pass thes rows to a datatable?
thanks for help
MD_NADA
|
|
|
|
|
Isn't your DataView based on a table already?
|
|
|
|
|
my dataview is aleady based on dataset but i filter the dataset by dataview
and i want to get the rows in the dataview in datatable
thanks for your help
MD_NADA
|
|
|
|