Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2006

Tip: Looking for answers? Try searching our database.

Change RichTextBox Font

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mario Hutter - 27 Mar 2006 13:19 GMT
Hi EveryBody

when i execute the code:
       Dim rtftext As New RichTextBox
       rtftext.Font = New Font("Courier New", 11)
       Debug.WriteLine(rtftext.Font.Name & " " & rtftext.Font.Size)
       Debug.WriteLine(rtftext.SelectionFont.Name & " " &
rtftext.SelectionFont.Size)
The result is:
       Courier New 11
       Courier New 11.25
why ist the Font.Size and the SelectionFont.Size not the same?
what can i do that there are the same?
Any help or redirection will be appreciated

regard's

Mario
Stoitcho Goutsev (100) - 28 Mar 2006 16:26 GMT
Mario,

The font size is not the only difference. The font's are form different
charsets for example.

I can't explain why is this happens at this moment, but when you set the
Font property the code sends EM_SETCHARFORMAT with wParam SCF_ALL, but when
you read the SelectionFont it sends EM_GETCHARFORMAT with wParam -1, which
is not defined value in the SDK header files (.NET1.x) or 1 (.NET2) which is
the correct value.

Anyways there is something fishy.

In any case it looks like in order to read the font you want from the
SelectionFont property you need to set it there.

My suggestion is when you create the control to set both properties. When
the control is empty the font you set in the SelectionFont will be the one
that is used to type the text. You need to set the Font property as well
though other wise when you press the enter key (start a new paragraph) the
think will not look ok until you start typing.

Signature

Stoitcho Goutsev (100)

> Hi EveryBody
>
[quoted text clipped - 14 lines]
>
> Mario
Mario Hutter - 29 Mar 2006 05:46 GMT
When i set the Font, it fill SelectionFont automatically . When i press Shift
+ arrow right, thenn delete, the Font will be convert to SelectionFont and it
is different.

> Mario,
>
[quoted text clipped - 36 lines]
> >
> > Mario

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.