473,698 Members | 2,630 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Find and Replace rich text without losing formatting

Hello,

Does anyone know how to implement find and replace in a
RichTextBox in a way that does not lose the text
formatting?

As a first attempt I tried rtb.Rtf.Replace (sFindText,
sReplaceText) , but that's no good since .Rtf includes all
the formatting codes, and .Replace will change richtext
codes that shouldn't be changed.

I know I can't set the .Text or .SelectedText properties
of the RichTextBox because that would kill the formatting.

Any ideas or examples? Thanks!
Kevin
Nov 20 '05 #1
1 7898
It looks like the answer might have something to do with
this code:

rtb.Find(sFindT ext)
rtb.SelectedTex t = sReplaceText

To replace all I'll loop through the text as long as Find
does not return -1.

I found a good example of how to do find and replace in
the vbCity.com forums at
http://vbcity.com/forums/topic.asp?tid=25133

Thanks,
Kevin
Nov 20 '05 #2

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

Similar topics

3
8674
by: Alfredo Agosti | last post by:
Hi folks, I have an Access 2000 db with a memo field. Into the memo field I put text with bold attributes, URL etc etc What I need to to is converting the rich text contained into the memo field in plain text. That's because I truncate the string text but if, when I truncate it there's a rich tag the code following the truncated string is corrupted. Don't know if it's clear enough.
2
1428
by: Raed Sawalha | last post by:
I have the following text:- Brian went to stadium to watch the soccer game, Brian MacWoods is bussiness man and very rich man. Brian likes to run every morning on beachside. the problem i have I get the list of words that should be replace in the provided text as follows:- Brian (ONLY) : should be replaced by Mr with Brian word itself==> will be
4
2769
by: David Davis | last post by:
Woll2Woll has a product for Delphi called Infopower which has a rtf control with a built-in word processor. Does anyone know of a third party control that has the same capabilities. I don't have the experience in Dot Net to write one myself. -- Thanks David Davis
5
1624
by: DigitalGENOcyde | last post by:
I am fairly new to working with programming so pardon my lack of knowledge, but I was hoping someone could assist me with working on a project. I am trying to make a Windows application using Visual Basic 2005 Express, and am wanting to have a menu bar with one of the drop downs being similar to that of the "Edit" drop down in most any other Windows app. I am wanting to find the code to perform such functions as Cutting, Copying and...
4
22992
by: Lauren Wilson | last post by:
Hi folks, We have a need to replace sub strings in certain message text. We use the Office Assistant to display help and often use the imbedded formatting commands. Those of you who have used them know they look like this: "{cf 5}" or "{cf 0}" or "{ul 1}" or "{ul 0}", etc. The commonality they have is that they are always 6 charters long and always begin and end with curly brackets. This all works great if the user is running the...
4
27178
by: coder | last post by:
Hello, I have a content management page where I can place rich text. On the confirmation page I display the rich text the user has inputted. However, I am noticing that when images are included in the rich text, the confirmation page is not displaying it. When looking at the source code, it is outputting: <img height=\"59\" alt=\"Gmail\"
5
5354
by: ARC | last post by:
Just found out something interesting with Access 2007... In table design, if you set a memo field to the new rich text option, and put that control on a form, set the control to rich text, you can only use the text formatting menus IF the control is on a parent form! If the control is placed on a form that is a subform, the mini format toolbar, and the access toolbar will not work! However, if you place the control on a self-contained...
16
11110
by: Neil | last post by:
I posted a few days ago that it seems to me that the Access 2007 rich text feature does not support: a) full text justification; b) programmatic manipulation. I was hoping that someone might know one way or the other whether that was true or not, or could point me to an article or help text that would. What I have seen so far online and in Access 2007 help seems to confirm the above. But that (or at least (b)) seems incredible that it...
11
12067
by: ARC | last post by:
Hello all, My app has an e-mailing feature where you can e-mail reports, as well as a bulk e-mail feature for e-mailing all customers (as separate e-mails). I allow the user to set the subject text, body text, and browse for attachments. I also allow 3 basic e-mailing options: Default mail handler (Mapi), MS Outlook, and a proprietary e-mailing client. I've always been curious how you would send rich text in the body message, or...
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7739
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.