Click here to Skip to main content
15,904,653 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi experts,

Let me explain my problem:
Imagine the MS-WORD(it contains many pages)
ok, now I want to create a windows form like this! I mean my form should contains many "Separate" pages,
So, how could I create this pages (page 1, page 2, page 3, ..., page 200, .. page 500 ! )?

Please note that my pages should have this abilitys:

1.The pages should contain picture in addition of text!( but how? )
for example it should have this possibility that I copy and paste text (include pictures) from MS-WORD document to my form pages in runtime, or any way else !

2.The user should be able to SAVE and LOAD his/her own document to a file such as .rtf ! ( but how? )
I mean save all his pages into one file ! ( like MS-WORD ! )

........
Now how could I solve my problem?
Is it possible to use RichTextBox as many as pages? I mean a RichTextBox per a page !
Is there any efficient way for it? (because of the amount of pages. for example 400 pages !)
I'll be glad for your help. i realy need it!
Thanks alot and excuse my bad english.
Posted
Updated 1-Mar-12 13:37pm
v2
Comments
Shahin Khorshidnia 18-Feb-12 18:14pm    
Plase tag your question.
Windows form? WPF? ...?
Mohamad77 7-Apr-12 9:14am    
hi shahin,
i realy need help in this!
you mentioned Dev Express XtraRichEdit, it's very good but unfortunately it does'nt support RTL languages!
i searched alot but found nothing like this application.
would you please suggest another control !?
thanks alot.

1 solution

Hello Mohamad

1. you can use some user controls. For example Dev Express XtraRichEdit. See it's Demo
2. Ms Word saves all pages to separated files. If you want to save data of a page in it's own file, (like ms word) have a property for your page class

C#
private string myFilePath;
public string FilePath 
{
   get
   {
      return myFilePath;
   } 
   set
   {
      myFilePath = value;
      Load(myFilePath);
   }
}

private void Save()
{
   //Saving code and using FilePath
}


After loading a new file, create a new instance of your page and initialize it's property.

for example:

C#
private void Load(string myPath)
{ 
  if (!System.IO.File.Exists(myPath))
      return;

  if(!IsBlank(this))
   {         
      WordPage wordPage = new WordPage();      
      wordPage.FilePath = myPath;
      this.FilePath = string.Empty();
      wordPage.Show();
      return;
   }

   //Loading code  
}

private bool IsBlank(WordPage wordPage)
{
   //code for checking if this page is a blank page or not!
}


And you can use a static Dictinary to prevent loading a file in 2 Windows.

C#
public static Dictionary<string, WordPage> dictionary = new Dictionary<string. WordPage>();

And:

C#
if(dictionay.ContainsKey("C:\\MyFile.txt"))
{
  //Requiered code ...

   return;
}


And in FormClosed event:

C#
private void myWordPage_FormClosed(object sender, FormClosedEventArgs e)
{
    dictionay.Remove(this.FilePath);
}


I hope it will help you.
 
Share this answer
 
v7
Comments
Mohamad77 20-Feb-12 7:30am    
hi shahin,
thanks for answering,
i've downloaded XtraRichEdit and i'll try it soon,
but i almost didn't understand your second note! would you please explain more? is it related to XtraRichEdit?
and how should i use these codes !?
thanks for helping.
Shahin Khorshidnia 20-Feb-12 18:52pm    
Hello,
Sorry for delay. (Internet problem)

No, It's not about XtraRichEdit.
The code can be used in your PageClass WinForm.
What is PageClass? A PageClass is a Customized Windows Form that it can behave like an editor page.

I just pointed to some methods and properties that you must implement and extend them.
Wich one of it's part is unintelligible for you?
Mohamad77 25-Feb-12 14:32pm    
thanks shahin,
i'll promise i'll try my best to extend your help!;) i just need the clue!
i searched more and more about pageclass, but i did'nt find anything, please guide me on PageClass! what is it!? do you know any article or refrences please?:)
Shahin Khorshidnia 25-Feb-12 16:27pm    
Hello,
If you paid attention to my comment, you might know it.
I told you that A PageClass was a customized Windows Form that it could behave like an editor page.

PageClass is a form that you have customized it. For example: you have a blank form. (It has not become a PageClass)
You put a XtraRichEdit control and a MenuBar or RibonBar on this form.
Then you write it's necessary code behind.
Now, you have a PageClass.

Ok, you wanted the clue! You have it now. Start writing your programme.

It's a homework, isn't it?
Mohamad77 25-Feb-12 17:04pm    
oh, thanks.
creating an editor with this Capabilities is the first step of my idea!and i choose it as my university project too.
XtraRichEdit doesn't support persian language!but it could help:)
i'll try more and i'll be pleased for your further help:)
thanks alot shahin.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900