|
Hi,
I have to display some xml document text in a richtextbox. All is ok except the formatting. Is there any usercontrol or plugin to do so?? The problem on hand is the xml document is in memory, not file. Moreover, this text will be changing based on the values of some comboboxes, ect. So, I cannot write to a file.
Please help.
Cheers
CNU
|
|
|
|
|
Hallo,
I am using the TcpChannel class in .Net Remoting. Does anybody know how to add authentication (username and password), or is it only available for the HttpChannel class.
Thanks for your help,
Björn
|
|
|
|
|
U could use CallContext to send the user info to the server application everytime u call a remote object.
Check out more about this here: CallContext[^]
|
|
|
|
|
Is their a way to add new properties to windows folder using C# .Eg I need a description property for folder where in I can type in some description relevant to the folder
Umesh.b
|
|
|
|
|
Whether or not it's possible has little to nothing to do with the language or framework. The file system does not expose an extensible system for defining properties for folders, though there is support using OLE streams for files. Windows NT provides a default OLE stream implementation for the "\005SummaryInformation" stream, while some formats - like Word Documents, MP3s, etc. - support their own implementation through a persistent file handler configured in the registry for that file class.
All this functionality is defined natively, however, and requires that you P/Invoke the necessary native APIs and define managed versions of native COM interfaces (using the ComImportAttributE , InterfaceTypeAttribute , and GuidAttribute ). There are projects documented here on CodeProject for doing just that.
For information about OLE streams and the "\005SummaryInformation" stream, I suggest you start by reading Properties and Property Sets[^].
To note, the default implementation that you see under the "Summary" tab in Windows Explorer for file properties uses alternative NTFS data streams. Custom handlers like that for Word actually store the information in the Word Document itself, which is how Windows 9X can see them, since Widnows 9X supports neither NTFS or alternative data streams (which is specific to NTFS). For MP3 files, for example, this information is reflected by the ID3 tags embedded in the MP3 file itself.
The documentation above references the native API functions and COM interfaces you need, and there's quite a bit. Just declaring these isn't enough, however, since you need to understand what an OLE stream is and how to access it. There are a couple different types of storage mediums, like IStorage and IStream . Streams (IStream ) may actually be contained within a compound storage structure (IStorage ), so checks are necessary to determine how you parse extended information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hello,
I am in the process of writing a "shrink wrapped" software product and I would like:
1. the end user to be able to define all of the labels/menu captions/error messages at runtime.
(eg. a customer may want to change the label 'Client' to 'Customer' etc. That way, 2 English speaking customers can have different captions to suit their own terminology. And 3 Portugese customers can do something similar and so on...)
2. the application to use locale-based dates/number formats.
3. the resource strings to be kept in xml files - not compiled into satellite dll's
Has anyone seen an article/sample app on the web anywhere that explains how to do this?
I basically want the end-user to be able to define their own terminolgy (if required) for any label or string that gets displayed to them but at the same be multi-culturally aware.
Thank you,
Daffrey
|
|
|
|
|
Hi,
I can't help you for all your points. But for point 2 about using the locale-based dates/number formats.
You can use Globalization and Localization. The System.Globalization namespace provides you with a number of classes that allow you to retrieve, make use and change the culture that your application code i susing to format dates, numbers and strings. The culture is set cia the Regional options. Localization means that you make use of these settings within your application. Every culture is defined by a 2 letter lowercase language code followed by an optional 2 letter uppercase Country code (f.e. nl-BE represents the Belgium Dutch regional setting.
You can ask the info using the globalization namespace. Then you can use the CultureInfo class.
<br />
Me.Label1.Text = CultureInfo.CurrentCulture.Name<br />
Me.Label2.Text = CultureInfo.CurrentCulture.DisplayName<br />
For the other items, you should create an kind of admin screen, where your users can define their word. Save this to your XML file and read this XML file.
I prefer to define by meyself the possibilities. Create languege textfile with everything translated. Use then resgen.exe to create your resourcefiles of each text file.
You can also work with XML-based resource files.
For this create your project, right click to add a new item and choose an Assembly Resource File . Add one for every language support. These files are XML files. Your job is to store the resources (name/value) in the data element. You can do this directly or using a dataset. Again use resgen.
As you can see, all of them are using regen to compile theses resX files into binary resource files. Only the first option isn't doing this.
Hopes this helps you a bit.
|
|
|
|
|
Thank you for your reply. I was originally thinking that I had to put every string into the "custom terminology" xml file, but I guess you are right. I probably only need to put in 30 or so words that end-users can configure based on their own terminology.
Some people might call a job a task, some might call it an issue and others may call it a fix.
I think I'll need to write template-based error messages. So an error message may look like:
"You can't delete the <<job>>. Permission Denied."
And then I'll just grab the <<job>> string from the "custom terminology" xml file...
Do you have any thoughts on whether it is better to put cultural resource strings for each language into 1 xml file? I haven't written a multi-lingual app yet, but I would imagine it would be easier to send 1 xml file per language to a translater rather than 1 form resource file that .NET normally uses....
Thank you for your reply.
Daffrey
|
|
|
|
|
You should start by reading Developing World-Ready Applications[^] in the .NET Framework SDK.
You should also understand the difference between globalization and localization, the former being how dates, times, and numbers are formatted, while the latter is how text is read according to the current language. Respectively, each is represented by CultureInfo.CurrentCulture and CultureInfo.CurrentUICulture , which could easily be different.
Developing a world-ready application using VS.NET is very easy. Develop your user interface, then use the PropertyGrid with the entire Form selected to set "Localizable" to true , then select the language. The neutral language is in whatever language you've developed the application (like "en-US" for U.S. English), so do not use that language. The neutral text will be compiled into resource files and embedded into your primary assembly (the assembly with the IL module(s) that is your compiled code), while any other languages are compiled into satellite assemblies. To make look-ups faster, you should define for your assembly an assembly-level attribute named NeutralResourcesLanguageAttributE using the locale/language in which you developed your application originally, like so:
[assembly: NeutralResourcesLanguage("en-US")] This will save a separate look-up for satellite assemblies when that particular language is the current locale and language. This is especially important if you're deploying your managed code via touchless deployment over the web.
I architected a solution using this concept, though I didn't use VS.NET because it's rather inefficient for enterprise applications. This will be greatly improved in Visual Studio 2005 using the ComponentResourceManager instead of the ResourceManager at design-time. Both classes have been defined since .NET 1.0, but the designer - up until VS 2005 - has been using the ResourceManager which can bloat your codebase by localizing every property attributed with the LocalizableAttribute , which is quite a few.
Even after compiling, either you or your clients can use the Winres.exe[^] tool. This only works if you use VS.NET's localization designer, or hack your .ResX files to make it look like VS.NET created the files.
There are a few articles on localization here on CodeProject, so I urge you to also search for them. For just localizing an application, however, it's quite easy. Use the VS.NET designer to localize an application and view what the designer did (it is, after all, just code and XML files (.ResX files, which are compiled into .resources files using the same functionality as the command-line tool resgen.exe). To make it easier, show all hidden files by clicking on the "Project" menu, then "Show Hidden Files" (or something similar to that).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi Heath,
Thank you very much for replying to my post, I really appreciate it.
Do you have any thoughts on whether it is better to put cultural resource strings for each language into 1 xml file? I haven't written a multi-lingual app yet, but I would imagine it would be easier to send 1 xml file per language to a translater rather than 1 form resource file that .NET normally uses....
However if this was done then it would be more work and a custom resource load routine would be required for each form.
The normal .NET way is to set the form localizable property to true and then select the language and go off and enter all of the labels for that language... To me that seems problematic because:
1. The same caption might be used on more than one form. If one developer has to update all of the "Name" captions on every form, then the chances of them missing one or more could be high for an application with many forms.
2. How does that work in practice for a translater? Does the translater need a copy of VS.NET installed and they go through each and every form in the designer? Or do you set the default language for each form. And if your application has 50 forms, then you send 50 resource files to a translater?
Did you face any of these issues when you did your multi-ligual application?
Cheers,
Daffrey
|
|
|
|
|
Normally you should have one resource file for each language. So when having three languages, you should have 3 resource files.
For your other question, I think (but I'm not sure) you can use the same caption for more than 1 form. So this should be no problem.
For the translator, you don't have to send 50 resource files but only the number of your languages. In these resource files everything is kept together for that language and as far as I know, your translator doesn't need a copy of VS.Net. As long as you give him the not compiled resource files, because these are XML files.
|
|
|
|
|
What you send to the translators doesn't necessarily have to be what you compile into resource files, so do whatever makes it easier. Since they are XML files (and you can also use plain text files using key=value pairs, but then you can only localize strings and not any Type that is attrbuted with a specific TypeConverter ), you can do just about whatever you want.
When you compile the resource files, however, they must be compiled into separate satellite assemblies. These satellite assemblies are identified by a specific culture.
Take a fully-qualified assembly name:
System, culture=neutral, version=1.0.5000.0, publicKeyToken=b77a5c561934e089 Notice the neutral? Primary assemblies (those assemblies that contain the IL module(s)) must always be neutral (but can contain your neutral language, which is why I mentioned using the assembly-level attribute NeutralResourcesLanguageAttribute for faster look-ups). Satellite assemblies replace "neutral" with whatever locale/language for which they were compiled.
Both the ResourceManager and the ComponentResourceManager (which extends the former) look-up resources in satellite assemblies using this information. You could create your own resource manager classes to look for resources in a single assembly, but there's so many problems with that.
It's inflexible and bloats the size of your assemblies when N-1..3 languages are necessary for any particular user (1..3 denotes cases when have locale-specific resources, which fallback to language-specific resources, which fallback to neutral resources). You also loose the ability to integrate with visual designers, unless you plan on implementing your own plugins for each designer instead of making the designers work for you (which is how the ComponentModel currently works).
Be sure to read-up on the classes I've mentioned as well as the links I gave you. It explains a lot of information.
Just going through an example of localizing a simple sample application and examining the code really helps, too. Create a new project, throw some controls on the form, assign some text, then localize it using the steps I've mentioned. Examine the source, compile the project, and examine the output. You can learn a lot from such an example.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi all,
Do the SQL Server CE on Pocket PC have the capability of recording locking ?
Thanks
|
|
|
|
|
From the documentation, locking is used by the engine which does not accept hints like with SQL Server 2000 and other mature RDBMS's. SQL Server CE is lightweight and does not implement many features.
For specific information on locking, please see the documentation listed above - especially the second item.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi~
I have encountered a very difficult problem and worked for a long time but still can't solve it. Pls help it.
The problem is :
There are two cases. One is for .net full vesion, one is for .net compact framework.
For the .net full version, "ListViewEx" is a class which extend listView.
class ListViewEx : ListView
{
ListViewEx()
{
}
protected override OnPaint(PaintEventArg e)
{
MessageBox.Show("ABC");
base.OnPaint();
}
The problem is the overriding OnPaint not be executed if a instance of this class newly be created but the base class (I don't know the method (OnPaint()) of the class "Control" or class "ListView" will be called and draw the listview only without showing message box.
However, the overriding OnPaint method seems works if the extended window control is not listview but button or panel. (Other control also not work). What is the problem?
For the CF case,
The case is that the if Class for example "ListViewEx2" extend the class ListView, the overriding Method OnPaint() still not work since the virtual void OnPaint method in the ListView Class is not supported.
However, as the ListView extend Control, and the control also got the virtual method OnPaint(), that mean the ListViewEx2 also got the virtual OnPaint method and which can be overrided by ListViewEx2. Then why the overrided method in ListViewEx2 does not executed?
Thanks
}
|
|
|
|
|
OnPaint is not used by the ListView control, as you could see by disassembling or decompiling the System.Windows.Forms.dll assembly.
Almost every control in Windows Forms simply encapsulates the Winodws Common Controls. In the case of some controls like ListView owner drawing the control simply by overriding OnPaint is not possible. To owner draw a List-View common control you need to override WndProc , define several custom drawing structures, and P/Invoke several native APIs.
For more information about the native List-View common control that is encapsulated by the ListView managed control, see http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/listview/reflist.asp[^].
For examples on this site about owner-drawing a ListView control, see the search http://www.codeproject.com/info/search.asp?cats=3&cats=5&searchkw=ListView[^].
You could also try searching this forum for "ListView" by clicking "Search comments" directly above this message area. We've talked about custom drawing a ListView quite a bit, and I know that I personally have posted several snippets of code that show how to draw certain parts through the custom drawing routines that the native Common Controls use.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Sorry - stupid question most probably - is C# platform independant like C++ or is it Microsoft based (like VC++)?
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
The language itself has been submitted for ECMA, the language specification is available here: C# Language Specification[^]. You can actually download (from Microsoft) the Shared Source CLI which is the ECMA CLI and C# language specification here: Shared Source Common Language Infrastructure 1.0 Release[^]. You will find specific namespaces such as System.Windows.Forms that have been written to wrap specific Windows functionality that is meant to target Windows, controls specifically for that namespace. There is also a port that will run under Linux called Mono which can be found here[^], this is targetting the ECMA standard.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Can we Serialize an enter Form?
|
|
|
|
|
And what do you mean by an "enter Form". It's rather ambiquous, and serialization doesn't really care what kind of object you're serializing so long as its attributed directly with SerializableAttribute . That attribute is not inheritted. Since the Form class is not attributed with SerializableAttribute , then you need to attribute your derivative class.
But ask yourself why you need to serialize it and what, specifically, you need to serialize. Much of the form is specific to that instance and should not be serialized (like the Handle ) if you plan on either re-creating it or saving it across multiple sessions (a session being separate logins, processes, etc.).
To control how your form (or any object) is serialized, implement ISerializable .
For more information on serialization, read Serializing Objects[^] in the .NET Framework SDK online. The SDK is also installed by default with VS.NET and can be installed stand-alone from http://msdn.microsoft.com/netframework[^].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi everybody I have a problem with DataGrid Control, That is:
I try to extract the column number and the row number by double click anywhere on the Datagrid
But there is no response by DoubleClick event when I try to DoublClick any Cell in the DataGrid ,the response occurs when I just click the Header Column or Header Row please can I get some help.
|
|
|
|
|
1.Firstly, DoubleClick event should fire, without any doubt. I do not find any problem in it.
2.Click or DoubleClick Event Handler of the DataGrid or other Controls has EventArg argument, you would not be getting the colum number / row number information from the EventArg . You should use either
MouseDown or MouseUp event Handler which has MouseEventArgs in the arguments.
MouseDown Event and HitTest method will get you the desired.
Refer the below link for details.
DataGrid HitTest Method[^]
|
|
|
|
|
sir,
i need to get system informations such as number of services,etc.i write queries such as select * from Win 32_service etc.But i don't know more about this table.I want to use some where clause also in the above query.for eg: i want to get all services whose mode is manual.I need column names for Win32_service
help mee
|
|
|
|
|
|
thank you very much,Mr.Nick Parker.You gave me the correct link
|
|
|
|
|