473,503 Members | 1,733 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 2128
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
2575
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...
1
2038
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...
2
63242
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...
7
8919
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...
0
1515
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...
2
1472
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...
2
2614
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...
25
4350
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...
6
2845
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...
0
7087
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...
0
7281
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,...
1
6993
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...
0
5579
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,...
1
5014
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...
0
3168
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...
0
1514
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 ...
1
737
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
383
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...

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.