473,387 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Richtextbox not loading

Shinobi
c#.net
I have 2 forms. richtextbox1 is placed in form1.
listbox1 is used in form2. selectedindex of listbox1 is passing path to form1.
by using this path i am trying to load richtextbox1 using this code

richtextbox1.loadFile(filepath);

But i can't load richtextbox without closing form2.

I tried this meathod.

form2 ob2=new form2();
ob2.showdialog();
string filepath=ob2.label1.text;
richtextbox1.loadfile(filepath);

In selectedIndex of listbox1 in form2

//geting filepath
label.text=filepath;
this.close();


I want to load richtextbox without closing form2.

Is there is any meathod to load Richtextbox in this way?

Help me....
Nov 19 '08 #1
3 1232
nukefusion
221 Expert 100+
There's a number of ways to do this. One simple method could be to pass a reference of your RichTextBox to form 2.

Maybe you could add a property to form 2 called "TargetTextBox" or something, like so:

Expand|Select|Wrap|Line Numbers
  1.         private RichTextBox _textbox;
  2.  
  3.         public RichTextBox TargetTextBox
  4.         {
  5.             get { return _textbox; }
  6.             set { _textbox = value;  }
  7.         }
  8.  
Then in form 1 you can set this reference before displaying form 2, like so:

Expand|Select|Wrap|Line Numbers
  1. form2 ob2=new form2();
  2. obj2.TargetTextBox = richTextBox1;
  3. ob2.showdialog();
Then in selected index event in form2 you can have full access to the textbox:

Expand|Select|Wrap|Line Numbers
  1. // Get file path somehow
  2. TargetTextBox.LoadFile(filepath);
Nov 19 '08 #2
MrMancunian
569 Expert 512MB
Hi,

The problem is in ob2.showdialog(); When you use this, the code will not continue to execute unless the dialog is closed. Try to use ob2.show();

Steven
Nov 19 '08 #3
nukefusion
221 Expert 100+
Hi,

The problem is in ob2.showdialog(); When you use this, the code will not continue to execute unless the dialog is closed. Try to use ob2.show();

Steven
That is true, but using the code sample Shinobi provided, you would still need a way to reference the RichTextBox in form 1 so that you could load it when the selected index event of the listbox on form 2 fires. As is, if the ShowDialog() command was changed to Show(), form2 would open, but the richtextbox would never be loaded.
Nov 19 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Reinhard Vornholt | last post by:
Hi, I have problems with the Windows.Forms.RichtextBox Control of the VS. I have a text that is written with WordPad. In this text there are tables. The cells in the tables are holding multiple...
0
by: Danny Carvajal | last post by:
Hello, I would like to load some text into a RichTextBox control with certain words in color. The only way I have been able to do this is AFTER the text has been loaded. And even that is slow,...
7
by: Tank | last post by:
I have RichTextBox in my dialog. Currently, I am loading the content from a file. Is there anyway to have the text 'binded' to it during compile time ? The idea is not to distribute the rtf file...
0
by: MSDousti | last post by:
Hi all! I'm writing an App, which uses some kind of pre-compiling a code before running it. This App is to run the code step-by-step. I used a richtextbox as my editor's base. I wanted each line...
0
by: landon.chelf | last post by:
I'm working with a RichTextBox control and am loading the following rtf into it. {\rtf1\ansi\deff0 {\fonttbl {\f0\fswiss Arial;} } \deflang1033\plain\fs20 {\pard...
0
by: Prabhakar | last post by:
Hi Friends, Do we have any provision for using RichTextControl or Loading Files in ASP.NET using C# as Code Behind??? We dont have RichTextControl, so i searched in Microsoft website but i...
2
by: AWesner | last post by:
I am currently working to create a VB program that will do more detailed in-file text search functions than windows has to offer. I have a form with a RichTextBox control to display the text that...
0
by: Pesso | last post by:
I'm loading a text file to a RichTextBox control to drag a selection of a text and drop it into a tree view control. It works except after the drag and drop operation the RichTextBox scrolls to the...
0
by: jorgedec | last post by:
Just for what it's worth: I was has having some strange behavior using a RichTextBox(RTB). What I was doing was I was loading some text into a RTB and and into an object that would let me do...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.