|
i am using sharpdevelop ide to develop a c# application. i just want to know how to create a resource file for a cs file. i am able to add a empty resource file. but then i have the burden of entering all the values of the fields in the localized form. what is the easy way to do that. is it possible to convert a cs file into a resouce file or create a new resource file from a existing cs file.
where we need just enter the values not names. ie i have a label in cs file which is named label1 i want to the get the resource file with name label1 where i need only enter the text which should be seen in the place of the label. i think i have explained it more than enough.
Thanks in advance
|
|
|
|
|
Sorry mate I think you need vs.net to do this. C# builder personal does it as well if you want to try that :
http://www.borland.com/products/downloads/download_csharpbuilder.html
Perhaps you could write an add-in for #d but its probably not easy.
The smaller the mind the greater the conceit.
Aesop
|
|
|
|
|
The best place to find this information would be in the documentation (if any) for SharpDeveloper, or at their web site.
Note, resource files (ResX files) really have nothing specifically to do with C# source files (CS files). They are XML files that contain key/value pairs like so:
<?xml version="1.0" encoding="utf-8" ?>
<root>
<xsd:schema id="root" xmlns=""
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string"
minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string"
minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string"
minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string"
use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="ResMimeType">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="Version">
<value>1.0.0.0</value>
</resheader>
<resheader name="Reader">
<value>System.Resources.ResXResourceReader,
System.Windows.Forms, Version=1.0.3102.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="Writer">
<value>System.Resources.ResXResourceWriter,
System.Windows.Forms, Version=1.0.3102.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Value1">
<value>ValueText1</value>
</data>
<data name="Value2">
<value>ValueText2</value>
</data>
</root> Some designers like VS.NET provide design-time authoring for these file when the ResX file is associated with a component (like a Form ). I don't know if SharpDevelop does this becuase I've never had a need to use it. If it does, you can still author this stuff by hand. If you need to store a type other than a string, you can use the type attribute in the data element to specify the fully- or partly-qualified type (like System.Drawing.Size, System.Drawing ). The type just needs to have a TypeConverter associated with it to convert to and from strings.
For more information, see Resources in Applications[^] in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi All,
I want to write an application which should display a pdf file, and some other features like searching,highlight text,zoom etc. Is there any free/paid controls available. I tried using pdf.ocx but it's very slow and also no feature for searching, highlight text etc. Any idea how to do this ?
Thanks
Mahesh Varma.
|
|
|
|
|
The Acrobat 6.0 ActiveX Control does have search and highlighting capability, as well as did 5.0 (maybe earlier versions as well, but I honestly don't remember). 6.0 has a button that literally reads "Search" and has a representative icon that 5.0 uses, binolculars - a common icon in many applications.
And since practically every computer has Adobe Acrobat (Reader) installed, you rarely have to worry about installing it. Just go to http://www.adobe.com[^].
If you want more options than this, please click "Search comments" at the top of the message forum because this has been covered many, many times before.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I Want to List the Table Names Of a MS Access Database Using ADO Connection.
This is How I tried
ADODB.Connection myConnection = new ADODB.ConnectionClass();
ADODB.Recordset rsTblNames = new ADODB.RecordsetClass();
if (optAccess.Checked)
{
ConnStr= "Provider=Microsoft.Jet.OLEDB.4.0;User ID=;Data Source="+ txtDbPath.Text +";Mode=ReadWrite;Extended Properties='';Jet OLEDB:System database='';Jet OLEDB:Registry Path='';Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False";
myConnection.Open(ConnStr,"","",0);
StrSql= "SELECT Name FROM MSysObjects WHERE Type = 1";
rsTblNames.Open(StrSql, myConnection, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockReadOnly,0);
}
But This returns a Error
|
|
|
|
|
Why don't you tell us what that error reads?
Besides, why are you using ADO.NET? It's much faster and for what you need can accomplish the same things. Your connection string doesn't change (although you could drop most of those options since they are mostly defaults and other unnecessary properties), nor does your SQL statement, just the code itself. This is, after all, the C# forum - a language targeting the CLR - so writing .NET applications and libraries is what this is about:
OleDbConnection conn = new OleDbConnection(string.Format(
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Mode=ReadWrite",
txtDbPath.Text));
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT Name FROM MSysObjects WHERE Type = 1";
OleDbDataReader reader = null;
try
{
conn.Open();
reader = cmd.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader.GetString(0));
}
}
catch (Exception e)
{
Console.Error.WriteLine("An error occured: {0}", e.Message);
}
finally
{
if (reader != null) reader.Close();
conn.Close();
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
To get a list of table names:
code:--------------------------------------------------------------------------------
SELECT Name FROM MSysObjects WHERE Type = 1;
--------------------------------------------------------------------------------
To get list of query names:
code:--------------------------------------------------------------------------------
SELECT Name FROM MSysObjects WHERE Type = 5;
--------------------------------------------------------------------------------
additional information:
code:--------------------------------------------------------------------------------
To get list of Forms:
SELECT Name FROM MsysObjects WHERE Type =-32768;
To get list of Reports:
SELECT Name FROM MsysObjects WHERE Type = -32764;
To get list of Modules:
SELECT Name FROM MsysObjects WHERE Type = -32761;
To get list of Macros:
SELECT Name FROM MsysObjects WHERE Type = -32766;
|
|
|
|
|
Hello Friends
We are inviting you to hotdotnet.
hotdotnet is "a tip of day" messaging system which send a C# source
code (and also same object code with VB) everyday. Only one code for
a day. Visit and join today. Enjoy it!
http://groups.yahoo.com/group/hotdotnet/join
Your respectfully,
Nuri Yilmaz - Musa Dogramaci
|
|
|
|
|
Wrong message board, wrong name, and link not clickable...
|
|
|
|
|
|
Hey,
I try to bind a datasource to my combobox. The datasource is an array of objects.
Then I set the cmb01.displaymember = "Propertyname1".
Till here everything works fine.
But then I will also set the valuemember like this :
cmb01.ValueMember = "PopertyName2".
At runtime I receive always following exception :
"Could not bind to new display member. Parametername is newdisplaymember"
What will this mean? And how I have to resolve it?
Tkx,
Jac
|
|
|
|
|
I am trying to figure something out. I have a panel control that contain other controls (I think, I am looking at some one elses code) but for some reason, I can't see the other controls. I can go to the properties window (the dropdown) and select them but I can't see them on my screen (they won't even highlight if I select them in the property dropdown). I right clicked on the panel control, and menued the "send to back" but nothing happens. Also sometimes, just sometimes all the controls do appear and then for some reason (unknown at this time) the all..... disappear...
Anyone?
Ralph
|
|
|
|
|
If you really want to know if the Panel contains those other controls, quick looking at the designer and look at the code. Every Control has a Controls property that contains a collection of Control s that are children of thet parent Control .
The other possibility is that there is some owner-drawing problem. Is this code overriding OnPaint or handling the Paint event on the Panel ? Somewhere in the initialization code, is the code using SetStyle to set styles incorrectly or overriding CreateParams (if a derivative class)?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
I'm trying to achieve inter-thread communication in C# and am having a few problems. In MFC/C++ for 'GUI' threads I achieved the same aim by using PostThreadMessage. Am I right in thinking that events are the way to go? I understand them and don't have a problem when in a single threaded application, but extending the principle is proving problematic.
Any suggestions? Am I on the right track?
Alastair
|
|
|
|
|
EDIT: When you spoke of "events", I assumed your were referring to the classes in System.Threading. If this is not what you meant (if you meant events like delegate/event), then ignore what I say about "Events".
What type of inter-thread communication are your trying to do?
Events are not quite as powerful as a PostThreadMessage. PostThreadMessage allows you to send some information. Events are things you have one thread wait for (or poll for). You would have to create an Event for each type of message you wanted to wait (or poll) for.
You're not restricted to synchonization objects for communication. You can always have threads call functions on other classes. This gives the most flexibility (the parameters can be whatever you want). If you go that route, you'll need to make your methods thread-safe (using Mutex's or the lock keyword).
If you can, give me an example of what you're basically trying to do. Is it one main thread spawning many worker threads and waiting to hear back from each one when it has something to report? A small break down would help me give better advice.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Hi David,
Thanks for your feedback. I'll try to give a concise and accurate explanation of what I'm trying to do. When I referred to events in my original post I did mean delegates.
In MFC I wrote a generic subsystem in which there existed the notions of Senders, Receivers, Messages, and the global messaging system (a singleton) which took care of passing on events of interest to appropriate parties (Receivers). Forget about Senders, that was a construct just to facilitate some nuance. So the important things are Receivers and Messages. Receivers are full blown classes which are doing some work within the system. Messages are also classes in their own right, and the nub of the system was that any receiver could register interest in any message, in particular specifying a function on the receiver class itself which would be invoked when that particular message was broadcast by some other object in the system. The whole thing hung together with a load of templated classes, functions etc. This system is a variant of Subject-Observer/Multicast.
Of course in C# we have beautiful constructs (like Java) such as retrieving all the methods for a given type, which makes life much easier because you can invoke a method against a particular object which was much more difficult in C++ for reasons I won't go into here.
Anyway, in C++ the global messaging system singleton executed in its own thread, and when some object wanted to broadcast a message they would obtain a lock on the singleton, call a method to broadcast said message and the singleton would then propagate this message to all interested objects by queueing the message for each thread, the singleton would then use the PostThreadMessage to indicate to the thread that messages were waiting for it, and when the thread received the context and the method referred to through the message map by the parameter to PostThreadMessage was executed, all messages queued up for that thread would then be propagated to the appropriate objects.
So what I was hoping to gain from the delegates/events was that I would be able to fire an event from the singleton to all threads and that an object within each thread would respond to said event and then retrieve all messages queued for objects instantiated within the context of their thread.
Am I going in the right direction do you think? I can supply a code example of what I'm trying if it would make things clearer.
Thanks,
Alastair.
|
|
|
|
|
A similar way is possible using an object-oriented framework like .NET. Instead of thinking procedurally, though, thing about how these objects react with each other, or with other objects.
For instance, you could code an event on the object that starts all the threads, for which they would handle. You should invoke these delegates attached to the event in an asynchronous manner, most likely. You could also add events to the threaded object but then the invoking class has to keep track of them and add and remove delegates. The first way makes more sense.
One thing that may help is that the C# compiler (I believe the VB.NET compilers does as well) generates synchronous (Invoke ) and asynchronous invocation methods (BeginInvoke , EndInvoke ). that are visible in the code editor when the delegates are declared in the current project. For more on asynchronous calls in .NET, see Including Asynchronous Calls[^] in the .NET Framework SDK.
It seem, though, like you are headed in the right direction. The only thing you have to watch out for is that you invoke the methods from the calling thread in the thread that contains the object.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Where is a discussion of the current and future optimizations that the C# compilers do? When I see things like the following I start to question my faith in csc being good at optimizing. (The same kind of thing shows up in cordbg when looking at the JIT code for a similar example.)
% cat y.cs
using System;
class A {
bool On { get { return true; } }
public void Print() {
if (On) {
Console.WriteLine("On");
}
}
}
class ConditionalTest {
static void Main()
{
A a = new A();
a.Print();
}
}
% csc /optimize+ y.cs
Microsoft (R) Visual C# .NET Compiler version 7.10.3052.4
for Microsoft (R) .NET Framework version 1.1.4322
Copyright (C) Microsoft Corporation 2001-2002. All rights reserved.
% ildasm y.exe
.method public hidebysig instance void Print() cil managed
{
// Code size 19 (0x13)
.maxstack 2
IL_0000: ldarg.0
IL_0001: call instance bool A::get_On()
IL_0006: brfalse.s IL_0012
IL_0008: ldstr "On"
IL_000d: call void [mscorlib]System.Console::WriteLine(string)
IL_0012: ret
} // end of method A::Print
%
At least the compiler eliminates the "if" test when "On" is replaced with "true" in the test.
|
|
|
|
|
Visual Studio has the nifty-looking selection colors when you hover over the main menu. I am in the process of writing a custom control, and I would like to use those colors (Windows Theme-depended obviously) for the selection mechanism in my custom control.
It seems System.Drawing.SystemColors isn't the proper way to get them; I can't find a SystemColor that is the correct color across all Windows Theme skins; for example, using the standard Blue Luna theme, SystemColors.InactiveCaptionText is the correct color for the internal region of the selection. However, using the Olive theme, that is not the correct color.
How can I get the correct colors needed to draw a VS-style selection?
Thanks ahead of time.
The graveyards are filled with indispensible men.
|
|
|
|
|
Sometimes Microsoft changes the normal colors of a control by changing the RGB components, like adding the difference between the current color and FF (for each component). This will lighten the color. There are also SystemColors that should already have such values, too, like ControlLight and ControlLightLight . You could try these as well.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
I wrote a program to go through all the SystemColors and compare them with what Visual Studio uses. The result was that there were some colors that Visual Studio uses (for instace, to draw a Visual Studio menu using the Luna Blue theme, SystemColors.Highlight can be used for the outer border, and SystemColors.InactiveCaptionText can be used for the inner region). However, if I switch themes, say to the Olive theme, SystemColors.Highlight and SystemColors.InactiveCaptionText no longer are the correct colors. In addition to checking all the SystemColors , I've also check through all system colors put through ControlPaint.Dark , .DarkDark , .Light , and .LightLight and still haven't found the correct colors!
Ack.
The graveyards are filled with indispensible men.
|
|
|
|
|
As I mentioned before, another thing they sometimes do is modify the RGB components of the color to get such an effect (adding to lighten, subtracting to darken). You could do the same thing if the SystemColors don't work for you.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Does anyone know how to programmatically position the mouse on a control in c#?
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|
|