473,699 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Set Text to Bold or Italics on a Multiple-RichTextBox Form?

91 New Member
Hello everybody,

I have a form on which I have several RichTextBoxes. Now, I'd like to be able to set text to Bold or Italics in each of these RichTextBoxes. On a given form like the following, we have these elements:

CommandButtonBo ld
CommandButtonIt alics

If we select (=highlight) some text in one of these RichTextBoxes and press one of the above Command Buttons, how can we determine which RichTextBox should be the target of this formatting? For example, we select (=highlight) some text in RichTextBox1 and then, we press CommandButtonBo ld to set the selected text to Bold. How can we know that the selected text in RichTextBox1 needs to be formatted? When another control gets focused, all the RichTextBoxes will lose focus.

When you select some text in a RichTextBox, it is the Active Control at that time. But if you press a Control that receives focus, the RichTextBox loses focus and another control will become the Active Control.

We can determine which control is Active at a given time using this command:
Expand|Select|Wrap|Line Numbers
  1. Screen.ActiveControl

But I don't know how to handle this problem.

Any help regarding this problem will be appreciated.
Dec 16 '11 #1
3 2065
8,435 Recognized Expert Expert
What I'd suggest is that you go to the SelChange or GotFocus event for each RichTextBox control, and place a value in some variable that tells you which one it is. Then, when a button is clicked, look at that variable to determine which one to work with.

I believe you'd want to define this as a form-level variable (that is, in the (General) - (Declarations) section of the form so that it's available to everything in the form.
Dec 18 '11 #2
91 New Member
Thank you very much. You're quite right.

I think SelChange, GotFocus, and LostFocus could help.

I'll try it.
Dec 20 '11 #3
8,435 Recognized Expert Expert
Glad we could help. Please let us know how it turns out.
Dec 20 '11 #4

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

Similar topics

by: Jean-Fran?ois Lacrampe | last post by:
Hello, I want to write a _very_ simple text parser that would replace a string like: "This is text with /italics/, *bold* and _underline_." and generate automatically something like this: "This is text with <i>italics</i>, <b>bold</b> and <span
by: Imaya Kumar | last post by:
Hi, i'm developing an editor in VS.NET using Rich Text Box Control. I need to make a selected text Bold. how can i do this? also i will have an Italic Button too. If i click Bold button the selected text has to become bold, and if i click italic button, the bolded text has to become Italic too with the bolded attribute. how can i do this? help me.. thanks imaya kumar
by: Piotrek Stachowicz | last post by:
Hi, Does anyone know if there is any way to display text in ToolTip as bold or italic? If so, how?! Piotrek
by: Radith Silva | last post by:
I have the following code: Private Sub Bold(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuFileBold.Click If mnuFileBold.Checked = True Then mnuFileBold.Checked = False ElseIf mnuFileBold.Checked = False Then mnuFileBold.Checked = True End If
by: Rich | last post by:
Could someone share how to toggle the font property of a label from regular to bold and back to regular? I have tried label.Font.Bold = True but get the error message that this property is ReadOnly. Label.Font.Style = FontStyle.Bold --> ReadOnly error again. Any Suggestions appreciated. Thanks
by: ahmad | last post by:
I want to make a particular option's text bold within a list in html, while all other options will get their normal font-weight, How can i do this???????? i tried <b>, <font> tags and style and class attributes to do this. but these didnt work. only text color or background color of a particular option can be changed.
by: Rex | last post by:
Hi, I want to make a particular piece of text BOLD (during runtime) in a textbox. for example: consider a string "The next stage for plaque collection will be at the end of January". I want to make the text "end of january" as bold, while rest of the string be as it is. This needs to be done in a report. Cheers Rakesh
by: Lewe22 | last post by:
Is it possible to enlarge or bold a selection of text within a text box on an access report. I want my text to appear as: "Report Unit Type: Registration" I can't find any function to do this. I am hoping for something similar to UCase() I currently have: ='Report Unit Type: ' & Ordinarily i would just have 2 seperate text boxes, one for the header and the other for the detail but i want the text to be centred across the page
by: cs_hart | last post by:
I have an app that sends email to clients. There is now a requiremnt to have one line in bold, as some clients seem to have overlooked some instruction. Right now the body is just a bunch of concatenated strings. How do I make one of these lines bold?
by: Apolakkiatis | last post by:
Property 'Bold' is 'ReadOnly'. << this error occurs when i type Textbox2.Font.Bold = True What am i doing wrong??? I have vb08..
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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,...
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...
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...
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...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.