|
Hi,
There are quite a number of options available.
1. Use of XmlSerializer- This would will be beneficial if some class data needs to be stored in XML Format.
2. If the XML document is "Well-Formed" then you can directly read the data from XML to a data set which then you can use to bind to some GUI control.
I think the serialization option will be better for you. For that you will have to write a class for the data to be stored and those all data-types must be serializable. I think you must be using primary data types only. So that wont be a problem.
After you write the class for the data to be stored, you will just need to call Serialize and Deserialize methods of the XmlSerializer class.
Hope all class and method names are correct.
If you want more information about XmlSerializer please check MSDN.
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Hello,
I have two projects (say proj1 and proj2) that are part of one solution. Both of them need to access a resource (.resx) file, which I can only add to one of the projects (say, to proj2). Is there a more graceful way of accessing this resource file (or making it common to both projects) than explicitly loading the assembly that references the .resx file into the one that doesn't? Thank you.
|
|
|
|
|
You should be able to include the common resource file in each project, though you may have to do this by hand-editing the project files (.csproj). For example, if both projects are at a peer level, with the resource file in a parent folder, you could include them in the project files like so:
<br />
<Compile Include="Properties\Settings.Designer.cs"><br />
<AutoGen>True</AutoGen><br />
<DependentUpon>Settings.settings</DependentUpon><br />
<DesignTimeSharedInput>True</DesignTimeSharedInput><br />
</Compile><br />
<EmbeddedResource Include="..\Resource1.resx"><br />
<SubType>Designer</SubType><br />
<Generator>ResXFileCodeGenerator</Generator><br />
<LastGenOutput>..\Resource1.Designer.cs</LastGenOutput><br />
</EmbeddedResource><br />
-Phil
|
|
|
|
|
Excellent! I just tried your solution and it works (not being able to edit the projects' properties in the designer view is a bummer, but editing them manually does the trick). Thank you, Phil!
Vladimir
|
|
|
|
|
Hello,
how do I construct a mathematical formula based on user's TEXT input?
It would be too complicated to explain what do I need to accomplish in my app, but let's just say that there's a textbox on a user form and based on what the user enters into that textbox, further calculation will be done.
E.g. if user enters "a + ( b / 2 )" and "a" and "b" will be recognized/parsed as valid variables with some internal meaning, the app will do certain calculation based on this formula. It would be too cumbersome to try to catch all possible input combinations the user might possible enter.
There must be some standard way on how to do this.
Is there any best practice on how to do this?
Thank you very much for any input,
Michal Kreslik
|
|
|
|
|
There have been several articles on CP about this.
Search keywords could be: symbolic, expression, evaluation
Luc Pattyn
|
|
|
|
|
Thank you very much, you helped me a lot by placing a correct name on the issue.
Thanks,
Michal
|
|
|
|
|
Hi
in php, there is a function called 'Preg_replace();' and i was wondering if i am able to do the same thing in c#?
|
|
|
|
|
Maybe if you explained a bit what it does we could help you.
I have no idea what I just said. But my intentions were sincere.
Poore Design
|
|
|
|
|
|
Hello all,
In vb6 there are properties called scaleX & scaleY for the image or form.
What the equivilant for these properties in C#
Thanks for HELP
|
|
|
|
|
The graphics object offers a scale transform.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I have a windows application with two button and one textarea. the button are start and stop. When I press start I want the program to execute a method x amount of times until I press the stop button. I'm displaying and increment number in the text area and when I run the program it doesn't display anything and it just hands there and I can't click the stop button. How can i fix this and get it to work?
<br />
private void startBtn_Click(object sender, System.EventArgs e)<br />
{<br />
stopBtn.Enabled = true;<br />
startBtn.Enabled = false;<br />
StartService();<br />
<br />
}<br />
<br />
private void stopBtn_Click(object sender, System.EventArgs e)<br />
{<br />
startBtn.Enabled = true;<br />
stopBtn.Enabled = false;<br />
StopService();<br />
<br />
}<br />
<br />
public void StartService()<br />
{<br />
int counter =1;<br />
while (start)<br />
{<br />
status.Text += counter +" test \n"; <br />
<br />
counter++;<br />
Thread.Sleep(5000);<br />
}<br />
<br />
}<br />
public void StopService()<br />
{<br />
start = false;<br />
}<br />
<br />
|
|
|
|
|
You should not execute Thread.Sleep() on the UI thread, since that freezes the UI.
There are two solutions for your problem:
1)
use a separate thread, with a loop and a Thread.Sleep
a while loop seems appropriate, make it while(running)
where running is a bool set true and false by your buttons
2)
use a Windows.Forms.Timer, start and stop it with your buttons
and execute your periodic job in its tick event (without a Thread.Sleep of course).
Luc Pattyn
|
|
|
|
|
thanks Luc for the quick replay, can you give me an example of solution #2?
|
|
|
|
|
Something along these lines maybe (code is not complete!):
using System.Windows.Forms;
class demo {
Timer timer;
int count;
Label myLabel;
public demo() {
timer=new Timer();
timer.Interval=5000;
timer.Tick+=new EventHandler(demo_tick);
}
btnStart_Click(...) {
timer.Start();
}
btnStop_Click(...) {
timer.Stop();
}
void demo_tick(...) {
count++;
myLabel.Text="Tick #"+count;
}
}
This is the simplest solution of the two, but it required the repetitive task
to be short (since it runs on the UI thread). If there is too much work to do,
you should go for a separate thread.
Luc Pattyn
|
|
|
|
|
Thanks a lot Luc, I will give it a try in a few.
|
|
|
|
|
hi
i want to know how to save and retrieve data to/from XML file simple...
can anyone help me ?
thanks
|
|
|
|
|
Take a look at the System.Xml namespace especially XmlDocument , XmlReader and XmlWriter .
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
using typed datasets..
they have WriteXml(...) and ReadXml(...) methods.
life is study!!!
|
|
|
|
|
Hi all,
I want to make custom voices for my TTS application. I have numerous voices from different companies yet I want to make my own.
Can anybody tell me of a good resource or a software to make my own custom voice and install it to the system with Microsoft Sam and all Lernaut and Hauspie etc.
Thank you
Bye
|
|
|
|
|
I have a task at my work and do not know how to do it.
Help!
Company has set of intranet forms (written long time ago) with hundreds of textboxes and radio buttons. My task to fill some textboxes programmatically from C# apps (which in turns pick up the text from DB).
For test I try to populate GOOGLE’s search textbox .
No success so far.
Help!
Frankww
frankwwttw@yahoo.com
|
|
|
|
|
Need Help !! is not a useful subject line.
What are the forms written in ? Basically, to do this in C#, you need to put a web browser control in your program, access the page's HTML and insert stuff into it, or you need to make changes to the original pages so they autopopulate themselves.
What have you tried ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
This is exactly how I start it!
I made a form with web browser control
Build a DOM tree.
I read links and saved it to DB.
Now I need to populate textbox (some of the textboxes do not have name to refer to)
GOOGLE search box is a good example.
Frank.
frankwwttw@yahoo.com
Frank
|
|
|
|
|
Frankww wrote: (some of the textboxes do not have name to refer to)
Then you need to change the original code, so they do.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|