473,387 Members | 1,724 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.

find function word processor

hi,

i am creating a word processor in c# and would like to know 2 things:

1. in my separate find form, how do i acess a richtextbox in my main form
(form1)?

2. i know the code to find stuff e.g.

richtextbox1.find(searchtermsbox.text);

but if you click the find button with this code at its onclick event, it
will only find the first time the text appears. what code do i need for a
button that finds all of the recurrances of the text e.g. a find next button?
--
Alvo von Cossel I of Germany
Nov 17 '05 #1
4 2133

Alvo von Cossel I wrote:
hi,

i am creating a word processor in c# and would like to know 2 things:

1. in my separate find form, how do i acess a richtextbox in my main form
(form1)?

2. i know the code to find stuff e.g.

richtextbox1.find(searchtermsbox.text);


There are several overloads of find. One uses the text only, one takes
an integer as the second argument, which is the position to start
searching from.

int pos = 0;

for ( int i=0; i<3; ++i )
pos = richtextbox1.find( searchtermsbox.text, pos+1 );

for example, will find the 3rd occurrence.

Matt

Nov 17 '05 #2
hi,

thanks for the answer. by the way, would you happen to know the answer to my
first question: in my separate find form, how do i acess a richtextbox in my
main form (form1)?
--
Alvo von Cossel I of Germany
Nov 17 '05 #3
Not unlike the source viewer you were making for your web browser, your best
bet would be to expose a property from the form containing the RichTextBox
that is accessible via the reference to the containing form from the calling
code.

Brendan
"Alvo von Cossel I" wrote:
hi,

thanks for the answer. by the way, would you happen to know the answer to my
first question: in my separate find form, how do i acess a richtextbox in my
main form (form1)?
--
Alvo von Cossel I of Germany

Nov 17 '05 #4

Alvo von Cossel I wrote:
hi,

thanks for the answer. by the way, would you happen to know the answer to my
first question: in my separate find form, how do i acess a richtextbox in my
main form (form1)?
You have two choices.

1) Make the richtextbox a public variable in form1:

public class Form1
{
public RichTextBox richtextbox1; // Change from private.
}

2) Make it a property of the form:

public class Form1
{
private RichTextBox richtextbox1;

public RichTextBox RichText // Or whatever you want to call it.
{
get { return richtextbox1; }
}
}

Then just use it from another form:

public class Form2 : Form
{
void function()
{
// Case 1: public variable
Form1.richtext1.<whatever>
// Case 2: property
Form1.RichText.<whatever>
}
}

Matt

}
}
--
Alvo von Cossel I of Germany


Nov 17 '05 #5

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

Similar topics

26
by: GS | last post by:
I am doing my first real embedded programming project and the supplied device libraries have a function definition that looks like this: void FCN(void) = { INTDEF, INTABS, (unsigned short)...
4
by: anonymous | last post by:
Thanks your reply. The article I read is from www.hakin9.org/en/attachments/stackoverflow_en.pdf. And you're right. I don't know it very clearly. And that's why I want to understand it; for it's...
34
by: priyanka | last post by:
Hi, I was wondering if we could parse or do something in the executable( whose source language was C). How can I use some scripting language like perl/python to find out the information about...
8
by: Ian Mackenzie | last post by:
Hi Guys I am VERY new to DB2 and have created a workingdays function to return the working days between 2 dates, but I get some compiler errors when running it: CREATE FUNCTION WORKINGDAYS...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.