Hi Guys,
Have an issue with the Font object.
I have a text box in which I can enter text and I have included a small
button which upon selection, should enable me to change the newly entered
text into bold. But it is not what is happening. All the previous
information entered in the regular font too gets changed to bold. The code
on the button click event handler is as follows ...
Note: A Font object is created as a Font object cannot be assigned values.
public void btnBold_Click(o bject sender, System.EventArg s e)
{
Font oldFont = Font;
FontStyle newStyle = Font.Style ^ FontStyle.Bold;
Font = new Font(oldFont, newStyle);
oldFont.Dispose ();
}
This is a code copied from Mickey Williams' Visual C# .NET text book (see
page 470). What I require is only the text that is going to be entered in
the text box after the selection of the btnBold should appear as 'bold' and
the earlier text already present in the textbox. The textbox used is
'RichTextBox' as the regular text box does not provide these facilities.
Example: a RichTextBox below ...
---------------------------------------------------------------------------
| This is just to demonstrate what I expect. Let us say, I want the text
|
| to be bold from this point
|
---------------------------------------------------------------------------
The moment, I type any character after the ' point ' in the above
RichTextBox after selecting the 'bold' option, all the characters from the '
This ' too gets changed to bold. That is something, I do not want.
Any help on this would be appreciated. Awaiting response at the earliest and
would be grateful.
p.s. Do not want to use the FontDialog to change my Font.
---
Regards,
Hariharan S 2 8755
Are you using a richtexbox yourself?
If you use a regular textbox the font applies to all text.
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Hey Hariharan,
You would use the RichTextBox's "SelectionF ont" property to accomplish your
task. Say your RichTextBox was named "rtf", then use something like this
code:
private void btnBold_Click(o bject sender, System.EventArg s e)
{
rtf.SelectionFo nt = new Font(rtf.Font, FontStyle.Bold) ;
}
Good luck!
-Noah Coad
Microsoft MVP & MCP
"Hariharan S" <fr********@tel evital.com> wrote in message
news:ex******** ******@TK2MSFTN GP12.phx.gbl... Hi Guys,
Have an issue with the Font object.
I have a text box in which I can enter text and I have included a small button which upon selection, should enable me to change the newly entered text into bold. But it is not what is happening. All the previous information entered in the regular font too gets changed to bold. The code on the button click event handler is as follows ...
Note: A Font object is created as a Font object cannot be assigned values.
public void btnBold_Click(o bject sender, System.EventArg s e) { Font oldFont = Font; FontStyle newStyle = Font.Style ^ FontStyle.Bold; Font = new Font(oldFont, newStyle); oldFont.Dispose (); }
This is a code copied from Mickey Williams' Visual C# .NET text book (see page 470). What I require is only the text that is going to be entered in the text box after the selection of the btnBold should appear as 'bold'
and the earlier text already present in the textbox. The textbox used is 'RichTextBox' as the regular text box does not provide these facilities.
Example: a RichTextBox below ... --------------------------------------------------------------------------
- | This is just to demonstrate what I expect. Let us say, I want the
text | | to be bold from this point | --------------------------------------------------------------------------
- The moment, I type any character after the ' point ' in the above RichTextBox after selecting the 'bold' option, all the characters from the
' This ' too gets changed to bold. That is something, I do not want.
Any help on this would be appreciated. Awaiting response at the earliest
and would be grateful.
p.s. Do not want to use the FontDialog to change my Font. ---
Regards, Hariharan S This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: hzgt9b |
last post by:
Using VS 2003, VB.NET:
I have a TreeView control filled with TreeNodes. When I create the TreeView,
I set HotTracking = True. Subsequently, I change the font (make the not bold
versus bold) on several of the TreeNodes in the TreeView but now, on those
changed nodes, the underline from the HotTracking no longer appears on the
screen (but, while being hovered over, the node still gets the HotTracking
font color change and the background...
|
by: Jon Davis |
last post by:
It looks like (looks like! ... not that there is!) there's a bug in the
TreeNode object. When you change the font, it does not readjust its size
appropriately.
The following code shows the boldface text truncated with everything after
"W" removed.
private void Form1_Load(object sender, System.EventArgs e) {
TreeNode newNode = new TreeNode("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
treeView1.Nodes.Add(newNode);
|
by: Dan Neely |
last post by:
Winform labels, buttons, etc don't respond to the normal/large/extra large
font settings that can be specified in display properties. Is there an easy
way to do an appwide detection+change at runtime for accescibility purposes?
I realize the bigger fonts will make things "interesting" regarding layout in
places, but if simply detecting and doing the font change is a major effort
the other problem is a moot point.
|
by: Rajesh Joshi |
last post by:
How to Change Datagrid's Column font change for a column.
and How fill Msflexgrid fill with particular Recordset at
runtime.
|
by: Jim |
last post by:
Working with VB.net under VS.Net 2003.
Have a simple form with a Button1. I want to change the
font on the button when the button is clicked.
Is there a way to Dynamically change the Font for Button1
from regular to bold, change the size etc. This line of
code:
Button1.Font.Bold = True
| |
by: Dhans |
last post by:
I have a MDI Application. From the container form I am setting the font for
the each controls in the MDI Child form. If I increase the size of the font
greater than the default, the text in each control displays the bigger size
as expected. But the location of the controls are changes and the GUI does
not look good. How do i prevent this location change in each controls, if i
change the font size in control?
|
by: ChillUmesh |
last post by:
can i change font in message box. if so can u help me out in this
thnx
|
by: Polaris |
last post by:
Hi Experts:
I'm using asp.net 2.0. Is there a way for my pages not to respond to the
IE's Page-Text Size?
Thanks in advance!
Polaris
|
by: Andrus |
last post by:
I need to save font selected by user by Ctrl+MouseWheel in Winforms
RichTextBox.
I tried override below but this does not remember font: in this method
Font.Size property
seems to be always *initial* Font size when RichTextBox is created, *not*
the font size set by ctrl+mouse wheel.
How to find the font size set by Ctrl+Mouse wheel ?
|
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: 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: 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,...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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...
| |