473,659 Members | 2,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# [Win App] - Regarding changing font of a TextBox Dynamically.

22 New Member
Experts,

I have a textbox which displays some contents in some font. I am providing the user a dialog which will provide him the options to change the font. The change is getting refelcted only when the user restarts the application.I want to change the font of the text box dynamically; ie; when the user selects the new font,it should be displayed in that font, just like "NotePad". How can I do that ?



With advance thanks and regards
Nikhil Unnikrishnan K
Oct 14 '08 #1
8 2142
Curtis Rutland
3,256 Recognized Expert Specialist
Show us the code you are using currently to change the font.
Oct 14 '08 #2
NIKHILUNNIKRISHNAN
22 New Member
Hi,

Expand|Select|Wrap|Line Numbers
  1. private void SaveUISettings(UIConfig uiConfig)
  2.         {
  3.             uiConfig.EditorFontString = editorFontTextBox.Text;
  4.             uiConfig.LogViewerFontString = logViewerFontTextBox.Text;
  5.         }
  6. .
  7. .
  8. .
  9. public void CallSaveUISettings(UIConfig uiConfig)
  10.         {
  11.            editorFontTextBox.Font = uiConfig.EditorFont;
  12.            logFileNameTextBox.Font = uiConfig.LogViewerFont;
  13.            SaveUISettings(uiConfig);
  14.         }
These are the two major areas where code changing occurs. But the font change effects only when we restart the application. Why it is not happening instantly ?
Oct 14 '08 #3
Curtis Rutland
3,256 Recognized Expert Specialist
Please remember to use [code] tags when you post code. This is a requirement on this forum.

MODERATOR
Oct 14 '08 #4
mldisibio
190 Recognized Expert New Member
That code does not say very much...you are saving the TextBox string in one function and setting the Font in another...we do not see where you create the Font from the string.

Nonetheless, at first glance it looks like you are setting the Font with the old settings, and then saving the new Font to uiConfig afterwards, which would explain why the Font change does not happen until you re-start, where it reads the last Font you saved.

If you are using uiConfig to set the Font, then try saving the new settings to uiConfig first and then setting the Font.
Oct 14 '08 #5
NIKHILUNNIKRISHNAN
22 New Member
Hi,

The "SaveUISettings " will be always having the latest provided font from uiConfig. It is saving the latest font only. Then it is using the same font to display in the text box. That is why I am confused !
Oct 14 '08 #6
NIKHILUNNIKRISHNAN
22 New Member
I am adding the following piece of code to do the same when restart button is clicked. [Restart button restarts the application].

Expand|Select|Wrap|Line Numbers
  1.  
  2. private void menuItemRestart_Click(object sender, System.EventArgs e)
  3.         {
  4.             Stop();
  5.             UIConfig uiConfig = new UIConfig();
  6.             IapetusConfig iaConfig = new IapetusConfig();
  7.             InitializeHSMS();
  8.             logViewerForm.Font = this.config.UIConfig.LogViewerFont;
  9.             uiConfig.EditorFont = this.config.UIConfig.EditorFont;
  10.         }
  11.  
  12.  
  13. .
  14. .
  15. .
  16. .
  17. .
  18. .
  19.  
  20.  private void SaveUISettings(UIConfig uiConfig)
  21.         {
  22.             uiConfig.EditorFontString = editorFontTextBox.Text;
  23.             uiConfig.LogViewerFontString = logViewerFontTextBox.Text;
  24.         }
  25.  
  26.  
  27.  public void CallSaveUISettings(UIConfig uiConfig)
  28.         {
  29.            editorFontTextBox.Font = uiConfig.EditorFont;
  30.            logFileNameTextBox.Font = uiConfig.LogViewerFont;
  31.            SaveUISettings(uiConfig);
  32.         }
  33.  
  34.  
I am getting the desired results only when the application is closed and restarted.
Oct 14 '08 #7
mldisibio
190 Recognized Expert New Member
I am suggesting you try this:

Expand|Select|Wrap|Line Numbers
  1.  public void CallSaveUISettings(UIConfig uiConfig)
  2. {
  3.   SaveUISettings(uiConfig);
  4.   editorFontTextBox.Font = uiConfig.EditorFont;
  5.   logFileNameTextBox.Font = uiConfig.LogViewerFont;
  6. }
  7.  
Oct 14 '08 #8
NIKHILUNNIKRISHNAN
22 New Member
Hi,

Can any one give any alternate plans ?
Oct 16 '08 #9

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

Similar topics

1
2585
by: Paul Gobée | last post by:
What is the parent element of a button (IE6 on Win, transitional mode)? Is it the BODY, the browser default stylesheet, or something else? Contra "body is parent-element": - Buttons with no style specified have a different font-size than the body's font-size. - If I change the body's font-size, a button with no style specified remains at the same font-size
1
2047
by: Hugo | last post by:
I have a dual boot machine, runs Win XP pro and Win XP Pro 64, XP boots from C and XP 64 boots from D. They both have VS 2005 Beta 2 installed. I have a webapp developed in Win XP (32) which has gone well and runs fine in XP. I Now want to get this same app running under IIS on XP 64.
2
63295
by: Mr.Baha | last post by:
Hello, I have a situation where I am appending text to a multi-line (rich)textbox in a C# form. Now depending on which event does the appendtext, i want to distinguish the lines in the textbox by having them written in different font colors. So my multi-line textbox will contain lines of various colored text. I tried setting the textboxe's ForeColor property, but quickly realized that the fore color will change every line within the...
7
8957
by: Ed West | last post by:
Hello, I have a simple form with some input boxes. After validation if one fails, then I would like to at the top of the page say something like "The following fields in red are required" and then change the label in front of the textbox or dropdown list to red... is this possible with asp.net? It seems you can only put a RequiredFieldValidator on the page, and if it fails validation then that text is displayed... ? Thanks
0
1526
by: Luis Esteban Valencia | last post by:
Hello. I have a datagrid with one row. I have a button that adds a new row. I am trying to implement that when the user selects one product it must change the price on the quantity column. Anyway when the user selects the first dropdownlist the dropdownselected_indexchanged is firring but when the user chagnes the second dropdownlist its not firing. aahh! if the user selects any of both dropdownlist the datagrid stays with only one row?...
2
1482
by: Peter Rilling | last post by:
I have controls on a page such as a textbox where I would like the font to match the rest of the page. The CSS style applied to the <body> tag does not seem to be used by the textbox. Can the textbox font be changed? Also, same thing for buttons.
2
2627
by: keith | last post by:
The function return quite rough pixels. e.g. if you use Font: Verdana, Font style:Regular, Size:8 and type 60 upper case character C, the functuion returns pixels 478.3639, but actualy it occupies a textbox that has width 545 pixels, that is about 13% difference. When using the function to get pixels and grow a textBox, the textBox is not big enough to show all characters.
25
4377
by: Blasting Cap | last post by:
I keep getting errors that pop up when I am trying to convert an application from dotnet framework 1.1 to framework 2.0. The old project was saved in sourcesafe from Visual Studio 2003, and I have opened it in Visual Studio 2005. I've cleared up most errors, but have one that beats the heck out of me. I have a page: sales/Item.aspx that has several datagrids in it.
6
2853
by: andrew.ames | last post by:
Hi I have a pretty basic windows application created in Visual Studio 2005 and VB.NET. I set my Form's font to Arial 8.25pt, so when i added a label and a button they automatically have a font of Arial and 8.25pt. Great.
0
8427
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, 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...
0
8851
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
8746
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
8525
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
8627
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
4175
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...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2750
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
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.