|
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-----
|
|
|
|
|
Hi,
I have a datagrid with several columns, one is "Finish Date", I would like that the rows that has a finish date greater than the current data have a different background color that the other one.
I have thought about create a calculated, hidden column, that will hold the column of the row, it's possible then bind that calculated column, to the background color of the row ?, Is there another easier way to do it ?
thanks in advance, greetings
Braulio
|
|
|
|
|
The unfortunate truth is that in ASP.NET, doing this with a DataGrid (System.Web.UI.WebControls.DataGrid , that is) is incredibly easier. You handle the ItemDataBound event, which gives you the item (the object being bound) to which you can set properties based on the data being bound, such as different font styles, colors, etc. Easy, huh?
I'm guessing you're not doing this in ASP.NET, though. Now it gets harder. The best way is to derive your own class from DataGridColumnStyle (or perhaps even form DataGridTextBoxColumn which you're most likely already using for the column style). If you choose the latter, it already exposes the TextBox that is hosted when you edit the cell. Note, though, that it is not enough to set the BackColor of the TextBox because it's only visible when the cell is being edited.
So, after deciding which you want to do (I recommend the latter), override the Paint method and - based on the value bound to the cell - paint the appropriate background.
The only thing left to do is modify the DataGrid initialization code. If you're not already using a DataGridTableStyle , you should because it gives you a high degree of control over the display and is still versitile enough to handle different data sources. See the DataGrid.TableStyles property for more info.
To this DataGridTableStyle , you add your various DataGridColumnStyle derivatives, such as the DataGridTextBoxColumn , the DataGridCheckBoxColumn , and your new-fangled derivative you created from above. If you already have one, just modified the source for that column to use your object instead of the DataGridTextBoxColumn instance.
It may sound like quite a bit of work, but this is an extremely versitile solution. Instead of handling special cases that require code every time you run into this problem, you make a single class that you can easily reuse - which is what component development is all about! If you create your own little library of handy classes like this, you won't even have to copy and paste source files from project to project - just reference the library assembly and specify the type. In the end, it definitely pays off and is "in the spirit" of the .NET base class library, i.e. extending it rather than working around it.
-----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-----
|
|
|
|
|
Thanks for your answer. I'm using windows forms, well a bit of work to make that, it's a pity that the VBA get effects like this so fast, and we have to spend some time into it ( how can you explain to that guy that the first time you need an hour to make a thing that he makes in five minutes ).
Another problem that I found on the Windows Form Datagrid, is that there not an easy way to fake the load of a result ( I mean, load only the first 1000 entries, then by demand load the others or all, something like that).
Greetings
Braulio
|
|
|
|
|
Hello everyone,
these days im thinking of building a chat server of my own with a chat application ofcourse too...
but im thinking about which technology i should use...
for me i already have knowledge in c++ and vb.net, but i believe that c++ is faster and i think c# is faster also from vb.net.
VB.net can do it, but again i think c# is faster...
so which language do u advice me to do it on, c++ or c# or vb.net, or even c++.net? and why? and which is faster? and is there articels that are helpfull that i cant read.
very thankfulllllll
|
|
|
|
|
Hello everyone,
these days im thinking of building a chat server of my own with a chat application ofcourse too...
but im thinking about which technology i should use...
for me i already have knowledge in c++ and vb.net, but i believe that c++ is faster and i think c# is faster also from vb.net.
VB.net can do it, but again i think c# is faster...
so which language do u advice me to do it on, c++ or c# or vb.net, or even c++.net? and why? and which is faster? and is there articels that are helpfull that i cant read.
very thankfulllllll
|
|
|
|
|
Good, so you know a few languages - now you need to understand the technology. All .NET languages - i.e., those that target the CLR - compile down to Microsoft Intermediate Languages (MSIL), an extension of Intermediate Language (IL). This means that no language is necessarily faster than one or another. The major differences between the compiled forms of VB.NET and C# are that VB.NET makes allowances for a few conventions (like, instead of using Return value , you can still do FunctionName = value like in VB). I've studied the differences between the assemblies that are generated and the IL is almost exactly alike in every case.
As far as C++.NET goes, the only time that it is a lot faster is when you use mixed mode assemblies, or those that use both native instructions and IL. First, this is bad in many cases (such as touchless deployments over the 'net) because unverifiable code is present in the assembly (that which the CLR does not and cannot manage). For the very same reason, it is also dangerous. The CLR is called the managed runtime because it manages all memory. When you use native code, you are again managing the memory (like in C/C++) and the CLR cannot manage it or even verify the types.
So, one is not really faster than the other when you're talking about pure .NET assemblies. Use whichever language you feel most comfortable, while being cautious with C++.NET because of its unverifiable nature (there are several articles in the .NET SDK that deal with this topic - you might want to take a look at them to fully understand the consequences).
-----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-----
|
|
|
|
|
hi
thank you alot for ur advice, its really valuable
i think im gonna work it on c#, although my experience is in vb.net, well mmm, i dont know why but i feel from my inside that c# is faster when there is stress on the server, i didnt read anything about it, but its just a feeling, so i dont know if its true
and i want to ask u , is there any tool i can use it to test my server when i do it under stress? i wish so
and if there any articles or anything that can help me in this
im really thankfull for uu
Kind Regards
|
|
|
|
|
I've tried the code below, and various code frm a number of books, I'm using V1.1. I know there is a image on the clipboard because I can paste a copy to the same folder as where I copy/cut the image.
(I know the code looks weird, but I've tried bothversions with the other one commented out)
If anyone has any code that works I'd be gratefull, this might also be releated to a problem whereby I can drag a image from a folder to my PB, but not from IE or Mozilla.
I'm very new to C#, so help really is needed
private void mnuPaste_Click(object sender, System.EventArgs e)
{
IDataObject d = Clipboard.GetDataObject();
if(d.GetDataPresent(typeof(Bitmap)))
{
Bitmap b = (Bitmap)d.GetData(typeof(Bitmap));
b.Save(@"m:\mybitmap.bmp");
MessageBox.Show("Bitmap saved to disk!!");
}
else
{
MessageBox.Show("No bitmap information was contained in the clipboard.");
}
// Create a new instance of the DataObject interface.
IDataObject data = Clipboard.GetDataObject();
// If the data is text, then set the text of the
// TextBox to the text in the Clipboard.
if (data.GetDataPresent(DataFormats.Bitmap))
{
//textBox1.Text = data.GetData(DataFormats.Text).ToString();
// Yes it is, so display it in a text box.
picCoverFront.Image = (Bitmap)data.GetData(DataFormats.Bitmap);
MessageBox.Show("paste") ;
}
}
|
|
|
|
|
trythat wrote:
(Bitmap)data.GetData(DataFormats.Bitmap);
This piece of code is important. A clipboard data object (also used in dragging and dropped) uses one or more clipboard formats. These are merely strings. .NET makes it easy by registering these clipboard formats for you. The important thing is that the strings match from source to target. When you copy a bitmap from most applications (including Windows Explorer, Office, etc.) - and even your application above (the lower part), you use the string value for DataFormats.Bitmap . In your target app (the upper code), you are using typeof(Bitmap) , which yields an entirely different string! Instead, do:
if (d.GetDataPresent(DataFormats.Bitmap))
{
Bitmap bmp = (Bitmap)e.GetData(DataFormats.Bitmap);
} The string you use isn't so much important (unless you want to be compatible with common formats when copying/pasting with other applications) as it is that they match between your source and target applications.
-----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-----
|
|
|
|
|
// Create a new instance of the DataObject interface.
IDataObject data = Clipboard.GetDataObject();
if (data.GetDataPresent(DataFormats.Bitmap))
{
Bitmap b = (Bitmap)data.GetData(DataFormats.Bitmap);
b.Save(@"m:\mybitmap.bmp");
MessageBox.Show("Bitmap saved to disk!!");
}
else
{
MessageBox.Show("No bitmap information was contained in the clipboard.");
}
Thanks for answering, but I still can't get it to work, I tried the above code and it always falls thru to the else statement, even though I'm trying to paste a jpg, all I really want to do is paste a image to my PB.
Do I need to have any code added anywhere else or SHOULD the above work?
|
|
|
|
|
I don't know off the top of my head, but copying a JPG file may not use the DataFormats.Bitmap clipboard format. The best thing I can tell you is to set a breakpoint at your condition and debug your app to see what formats are there. You can also use ClipSpy[^] to also see what formats are being used.
What exactly are you copying this file from? If you're doing it in your own program, make sure you copy the data into the DataObject the same way and using the same clipboard format as you do when you retrieve it.
-----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-----
|
|
|
|
|
Thanks again, downloaded Clipspy - I'll have a good read first
I'm trying to copy mainly from other folders, I can now drag&drop from another folder, but not from another program - mainly IE. I only want to paste/drag&drop to my program, and the books make it look so easy they all seem to be the same code I pasted in my first message - so I'm not sure what I'm doing wrong.
|
|
|
|
|
The only thing you seem to be doing wrong is using the wrote clipboard format. Be sure to copy a JPEG from Windows Explorer into the clipboard, then examine it with ClipSpy to see what formats are there. If DataFormats doesn't have the string you need represented, just pass the string itself - that's all that it is). If nothing else, read the sections of the Windows Shell documentation in the Platform SDK that deal with the clipboard, dragging and dropping, and clipboard formats. I did many many years ago and I'm glad I did.
-----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-----
|
|
|
|
|
Thanks Heath, I'll try that out and see what I can manage, I'm also going to have a quick gander at the Clipspy source to see if I pick some tips up from there as well.
Thanks again -
|
|
|
|
|
I'm currently writing a C# MIME parser and a problem has occured, encoding
I've written a hack that converts iso-8859-1 to a readable form by taking out the ASCII-value of the characters and then replace the code (for example =E5 is the swedish character 'å') with the corrent character. But today I got a nasty spam with the following text (in the header) that I don't know how to encode:
From: =?koi8-r?B?6OhMLfRB6EkgKDk5NS04Mjk0KQ==?= <mc7yfccu@buch.de>
The charset is koi8-r, but then? According to another email-client the correct translation is èèL-ôAèI (995-8294) <mc7yfccu@buch.de>
Is there a general way of converting strings with known encoding-strings like koi8-r, iso-8859-1 etc?
// Niklas
|
|
|
|
|
Take a look at Encoding.Convert (and the various encoding-related classes). This converts to/from ASCII, UTF7, UTF8, and Unicode, so any charsets should be able to convert.
-----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-----
|
|
|
|
|
Hi,
This encoding is called as Canonical encoding.
Format: =?charSet?type[Q or B]?encoded string?=
Q - quoted-printable encoding
B - base64 encoding
You can see my developed mime parser, it hanles all this stuff.
http://www.lumisoft.ee/lsWWW/Download/Downloads/Net/;
P
|
|
|
|
|
hi !
i would need some performance comparisons. (charts, ...)
best would be java , c#
espacially for socket-operations.
does anybody know where to find such info.
THANKS !!!
|
|
|
|
|
This has been covered to death in this forum. Please click the little "Search Comments" link above. It's not worth repeating for the 100th time.
-----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-----
|
|
|
|
|
Hi,
I compile my c# apps on c# builder/visual studio .net at my XP , and it does work great , the problem occurs when I try to run the excutable on another XP/computer , it gives an error message
"The application failed to initialize properly(0xc0000135).Click on OK to terminate the application" , the hexa number isn't stable it changes for each excutable.
what/where may be the problem?
hope you reply soon
thanks,
shon9
shon9
|
|
|
|
|
Hi
Setup on another computer Framework.NET
|
|
|
|
|
your probably missing a .dll that the particular program needs to run.
/\ |_ E X E GG
|
|
|
|
|
Hi, I really nead a C (not c++) code for deconvolution of signals (not images)
Is there anybody that can help me? I'll be very happy.
Thanks, Angeluna.
|
|
|
|
|
Angeluna wrote:
Is there anybody that can help me?
No
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|