|
I am trying to develope a small RTF writer to generate project report at runtime, with a limited RTF writing capability. RTF is one page document only, untill we intentionally put page breaks in it and Project report consists of number of pages. Thus, on what criteria it should be decided to insert page break? How to keep track of page's empty area before inserting anything?
OR
The next issue to overcome is to determine how to page-break text that is too long for one page.
Is there some way to identify exactly how many characters I can print before I run out of room in the current rectangle that defines the output, and do to a new page.
RTF specification 1.6 to 1.8 doesn't give any example regarding this issue.
Please guide.
|
|
|
|
|
Hello, I posted a similar question a couple of days ago, got some advice but don't seem to be able
to make this one work anyway. Here is the problem: I have a custom class derived from treenode that I want to be able to perform drag'n'drop on to another instance of the same application. I want to serialize the treenode so I implement the ISerializable interface and add a constructor taking a SerializationInfo and a StreamingContext parameter
The class essentially looks like this:
<br />
[Serializable()]<br />
public class InheritedTreeNode : TreeNode, ISerializable<br />
{<br />
bool bool_property1, bool_property2, bool_property3;<br />
string string_property4;<br />
public InheritedTreeNode() : base() {}<br />
...<br />
}<br />
here's what the serialization code in the InheritedTreeNode does:
<br />
public void GetObjectData(SerializationInfo info, StreamingContext context)<br />
{<br />
info.AddValue("bool_property1", typeof(bool));<br />
info.AddValue("bool_property2", typeof(bool));<br />
info.AddValue("bool_property3", typeof(bool));<br />
info.AddValue("string_property4", typeof(string));<br />
<br />
ArrayList al = new ArrayList();<br />
foreach(InheritedTreeNode itn in this.Nodes)<br />
al.Add(mc2);<br />
info.AddValue("Nodes", typeof(ArrayList));<br />
}<br />
...and here is how it is Deserialized:
<br />
public InheritedTreeNode(SerializationInfo info, StreamingContext context) : base()<br />
{<br />
this.bool_property1 = info.GetBoolean("bool_property1");<br />
this.bool_property2 = info.GetBoolean("bool_property2");<br />
this.bool_property3 = info.GetBoolean("bool_property3");<br />
this.string_property4 = info.GetString("string_property4");<br />
<br />
ArrayList al = (ArrayList)info.GetValue( "Nodes", typeof(ArrayList) );<br />
foreach(MyTreeNode2 mc2 in al)<br />
Nodes.Add(mc2);<br />
}<br />
now for drag'n'drop i do this:
<br />
BinaryFormatter bf = new BinaryFormatter();<br />
MemoryStream ms = new MemoryStream();<br />
bf.serialize(ms, instance_of_a_tree_node);<br />
<br />
DataObject dObj = new DataObject("InheritedTreeNode", ms)<br />
theTreeView.DoDragDrop( dObj, DragDropEffects.All );<br />
and when dropping in the other tree view the code looks like:
<br />
<br />
IFormatter formatter = new BinaryFormatter();<br />
MemoryStream ms = (MemoryStream)e.Data.GetData( "InheritedTreeNode" );<br />
ms.Position = 0;<br />
InheritedTreeNode data = (InheritedTreeNode)formatter.Deserialize(ms);<br />
<br />
this will throw an exception in the deserialization constructor at the first info.getBoolean() call
saying that it is an invalid cast...
Is the problem that i put the memorystream object on the clipboard, because it's a reference? In that case, how do I put copy of the bytes contained in it onto the clipboard in global memory so that other instance can retrieve it?
the byte[] of the memory stream
|
|
|
|
|
Hi all. I know this may seem like a stupid question but hey I'm new @ this.
Please tell me how to add a global variable. I come from vb and it was easy to do it there but I've tried everything in c#, please help.
Thanx
:P
|
|
|
|
|
use static variable for this goal
|
|
|
|
|
hi,
you can use app.config file for accessing globel level variables in C#.
steps.
add an xml file to your solution. And give the value to your globel variable.
eg
<configuration>
<appSettings>
<add key="sourcename" value="DummyDb" />
<add key="DtFormat" value="MM-dd-yyyy" />
</appSettings>>
<
|
|
|
|
|
Hello,JayJ.
First of all,have you studied the cpp language?
Add a global variable there are many methods.
for instance:
1. Add a field into the mainclass which contains the main method.
Such as "public int G_variable = 0 ;".You can even add some modify words as static,readonly.Remember readonly field must be initiated in the constrcution method.
2.C# is completely oo,so everything is class.So more formal way to add a global variable is to write a public class and make the global variable be a field of the class.I suggest you use this way.
Enjoy it!Welcome to world of C#!
Never understand
ridical version!
|
|
|
|
|
ILoveCS wrote:
C# is completely oo
I would disagree with that statement. There are many things that are Object Oriented that C# does not have, such as multiple inheritance.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
But does that make C# not OO?
By pointing at something C# HAS that is NOT OO would maybe better falsify the statement.
Agree? Disagree?
|
|
|
|
|
misterbear wrote:
But does that make C# not OO?
The original statement said "completely OO". Implying that the set of features in C# includes at exactly all the features in OO.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Thanx guys, appreciate it :P
|
|
|
|
|
I'm afraid i can not agress with you.
I don't think mutiple inheritance is the property of standard oo.
It is just implemented in cpp.
Java and C# don't support multiple inhertance.A class can implement many interface but not inhert many fathers.
In your opinion,what the "completely or standard" oo is?
Nice to discuss with you.
Never understand
ridical version!
|
|
|
|
|
ILoveCS wrote:
I don't think mutiple inheritance is the property of standard oo.
It is just implemented in cpp.
And Smalltalk, Eiffel, and Magik and some other OO languages that I've never used.
ILoveCS wrote:
In your opinion,what the "completely or standard" oo is?
You are the one who mentioned "standard OO". I don't know what that is. However I know that "complete OO" (which is what you said originally) must include a set of all features that are regarded as Object Oriented. Multiple inheritance is an object oriented feature.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Hy everyone!
I added an Eventhandler to my Textboxes which is invoked when you leave a TextBox (this.TextBox.Leave)
In there I do check if the Length of the input is at least 4 characters. If not then there is an error message and I do want to reset the cursor in the TextBox until there are at least 4 characters.
What I managed to do so far is to code the event handler which checks for the length and displays an error message, if the length is smaller than 4 characters. But I didn't manage to refocus the TextBox to force correcting the input until it is within the limit.
So how do I have to reset the cursor in the TextBox where the incorrect data has been insert and where the leaveevent just took place?
Thanks.
Stephan.
|
|
|
|
|
Hy!
I just solved it myself!
Just had to add a TextBox.Focus() in the eventhandler, then it's refocused 'til it's within the limits!
Stephan.
|
|
|
|
|
Stephan,
you could also use the validating event.
This has a System.ComponentModel.CancelEventArgs e parameter.
Then
if (TextBox.Text.Length < 4)<br />
{<br />
e.Cancel = true;<br />
}
This will keep the focus in the textbox.
Kev Pearman MCP
|
|
|
|
|
In my Winapp there are a web browser control(axWebBrowser1) and two button control(Load and Save),First i load file(suppose 1.htm) to axWebBrowser1 then when i save it's content there is a exception said the Process can not visit the file because another application is using the file.
Why? How can i get rid of it?
|
|
|
|
|
above question is bring forward by me.
here is the button click
private void save_Click(object sender, System.EventArgs e)
{
UCOMIPersistFile file = (UCOMIPersistFile)axWebBrowser1.Document;
file.Save(Application.StartupPath+"\\temp.htm",false);<----Exception
}
private void button2_Click(object sender, System.EventArgs e)
{
object oEmpty =null;
axWebBrowser1.Navigate(Application.StartupPath+"\\temp.htm", ref oEmpty, ref oEmpty, ref oEmpty, ref oEmpty);
}
|
|
|
|
|
It sounds like you cannot change the file because something has a lock on it - possibly your own program.
First be sure to close the file stream (don't just rely on it falling out of scope to close it). Also do a try-catch-finally block around the save, so you can attempt to clean up your file object properly even on the exeception.
If that doesn't work try to not load up the document in your browser control. Just save it and try opening it up in IE. Then keep it open and try saving again. That way you can see if it's your application in particular that is locking the file or something else.
/**********************************
Paul Evans, Dorset, UK.
**********************************/
|
|
|
|
|
why use below sentence don't appear exception:
private void button2_Click(object sender, System.EventArgs e)
{
object oEmpty =null;
axWebBrowser1.Navigate(Application.StartupPath+"\\temp.htm", ref oEmpty, ref oEmpty, ref oEmpty, ref oEmpty);
((IHTMLDocument2)axWebBrowser1.Document).designMode="On";<---Add only
}
|
|
|
|
|
I want to give a special color to any item of what we see on the screen and not all the content of the richTextBox.
So I need to know any time the index of the first and last char we see in the richTextBox (regardless of the way that screen changes eg. trackpoint of a notebook)
Is it possible to know that ?
|
|
|
|
|
You can use GetCharIndexFromPosition() to determine the index of the character closest to a Point you supply.
For the first visible character this would be the top left corner of your RichTextBox and the last character can be found by supplying the lower right corner's coordinates.
mav
|
|
|
|
|
|
I got a problem with a Isnumeric I'm using. I keep getting the error. "Not all code paths return a value" Please help. Heres the code.
public bool IsNo(char[] test)<br />
{<br />
foreach(Char chrMine in test)<br />
{<br />
if (chrMine >= '0' && chrMine <= '9')<br />
{<br />
return true;<br />
}<br />
else<br />
{<br />
return false;<br />
}<br />
<br />
}<br />
<br />
<br />
}
Thanx
|
|
|
|
|
What happens if the foreach loop contains nothing to loop over? What is returned in that instance?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
u have specify what has to be retured if both the if and else condition fails. so if u say return true or false as the last line then you wont get this error.
Regards
GP
|
|
|
|