Click here to Skip to main content
15,891,423 members
Home / Discussions / C#
   

C#

 
GeneralRichTextBox contents in a DB Pin
phimix3-Dec-03 5:19
phimix3-Dec-03 5:19 
GeneralRe: RichTextBox contents in a DB Pin
Heath Stewart3-Dec-03 6:27
protectorHeath Stewart3-Dec-03 6:27 
GeneralRe: RichTextBox contents in a DB Pin
Joel Lucsy3-Dec-03 8:43
Joel Lucsy3-Dec-03 8:43 
GeneralRe: Creating a new database... Pin
Heath Stewart3-Dec-03 5:15
protectorHeath Stewart3-Dec-03 5:15 
GeneralCreating a new database... Pin
Amirjalaly3-Dec-03 5:09
Amirjalaly3-Dec-03 5:09 
QuestionHow to display text the same way as printed? Pin
Loke13-Dec-03 3:59
Loke13-Dec-03 3:59 
GeneralCultureInfo Pin
Member 7439443-Dec-03 2:43
Member 7439443-Dec-03 2:43 
GeneralRe: CultureInfo Pin
Heath Stewart3-Dec-03 4:30
protectorHeath Stewart3-Dec-03 4:30 
Simply refreshing (ala Control.Refresh) or resuming the layout (ala Control.ResumeLayout) won't do it. Refresh merely invalidates the control's region and forces a repaint. ResumeLayout is only used during initialization of the control to make sure that no layout code is executed (as long as the control implements it right) until the method is called. This is many times necessary and often times save CPU cycles.

Switching the CurrentUICulture is only the first step. Normally, you do this in a program before calling Application.Run in your app's entry point (static Main). This is also done automatically on non-English Windows OSes or Windows with an MUI pack installed and enabled for the current user. This ensures that the main thread (the thread on which all UI operations should be / need to be done) - and any threads that it spawns - use the culture for both regional information (dates, times, numbers, etc.) and for the UI.

The problem with doing this after the UI thread is executing is that you need to re-initial all relevent values. Basically, you need to do everything found in InitializeComponents (if using the VS.NET form/control designers) except instantiating the control and adding it to its would-be parent's Controls collection. Any properties that should be localized (like Text, Size, Location, etc.) in your app need to be reassigned. Having set the CurrentUICulture prior to this act will ensure that the right localized values are obtained (if available, otherwise the primary assembly's resources are used).

Also, to avoid unnecessary look-ups for the language in which the app and its libraries were written (for example, everything I develop is inherently in en-US), you should use the NeutralResourcesLanguageAttribute (an assembly-level attribute) that tells the ResourceManager (et. al.) that it can find the specified culture's resources in the primary assembly (rather than performing look-ups for an appropriate satellite assembly, which can very expensive when touchless deployment over the Internet).

I know it doesn't sound easy, but its necessary. The docs affirm as much. One thing that would make it slightly easier - but it will break the ability to use the designer (personally, I don't like the designer after initial layout, so I could care less) - is to separate the initialization code from the property assignment code, so that you instantiate and add controls to their parents' Controls collections in one method, and assign all the property values in another. You should still call SuspendLayout and ResumeLayout, as well as BeginInit and EndInit for types implementing ISupportInitialize (again, the form/control designers will do this automatically), when appropriate in the method that instantiates the controls (after instantiation of course). Call the beginning methods before calling the property-assignment method, and then call the ending methods after the method returns.

Then, when the culture is changed, you need only call the property-assignment method again. The controls are already initialized and any changes to their Size or Location would also be reflected.

 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralDataBinding Row DataGrid Pin
Braulio Dez3-Dec-03 2:32
Braulio Dez3-Dec-03 2:32 
GeneralRe: DataBinding Row DataGrid Pin
Heath Stewart3-Dec-03 4:15
protectorHeath Stewart3-Dec-03 4:15 
GeneralRe: DataBinding Row DataGrid Pin
Braulio Dez3-Dec-03 21:06
Braulio Dez3-Dec-03 21:06 
Generalchat server Pin
Mahmoud Manasrah3-Dec-03 1:20
sussMahmoud Manasrah3-Dec-03 1:20 
Generalchat server Pin
Mahmoud Manasrah3-Dec-03 1:19
sussMahmoud Manasrah3-Dec-03 1:19 
GeneralRe: chat server Pin
Heath Stewart3-Dec-03 3:57
protectorHeath Stewart3-Dec-03 3:57 
GeneralRe: chat server Pin
Mahmoud Manasrah3-Dec-03 20:50
sussMahmoud Manasrah3-Dec-03 20:50 
GeneralCan't paste a image to PicBox Pin
trythat3-Dec-03 1:05
trythat3-Dec-03 1:05 
GeneralRe: Can't paste a image to PicBox Pin
Heath Stewart3-Dec-03 3:51
protectorHeath Stewart3-Dec-03 3:51 
GeneralRe: Can't paste a image to PicBox Pin
trythat3-Dec-03 6:55
trythat3-Dec-03 6:55 
GeneralRe: Can't paste a image to PicBox Pin
Heath Stewart3-Dec-03 8:16
protectorHeath Stewart3-Dec-03 8:16 
GeneralRe: Can't paste a image to PicBox Pin
trythat4-Dec-03 0:51
trythat4-Dec-03 0:51 
GeneralRe: Can't paste a image to PicBox Pin
Heath Stewart4-Dec-03 5:07
protectorHeath Stewart4-Dec-03 5:07 
GeneralRe: Can't paste a image to PicBox Pin
trythat4-Dec-03 5:16
trythat4-Dec-03 5:16 
GeneralC# MIME parser Pin
pahlsson3-Dec-03 0:53
pahlsson3-Dec-03 0:53 
GeneralRe: C# MIME parser Pin
Heath Stewart3-Dec-03 3:46
protectorHeath Stewart3-Dec-03 3:46 
GeneralRe: C# MIME parser Pin
Ivar Lumi3-Dec-03 4:12
Ivar Lumi3-Dec-03 4:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.