|
Thanks.... I'll check that out...
|
|
|
|
|
I have a windows form and the first thing I want to happen is for a MessageBox to ask a Yes/No question after the form loads. However, I want the form to fully render itself before the MessageBox pops up. If I put the MessageBox.Show in the form constructor or in the form's Load method, the MessageBox appears first thing and the form does not appear until the user answers the MessageBox.
What do I need to do?
Thanks,
Mark Mokris
|
|
|
|
|
Hello,
Maybe you could call the Form's Invalidate method before showing the messasge box.
Peter
|
|
|
|
|
Is the form supposed to wait on the message box to do something? If not, you can create a thread to show the message box. This will assure that your app will paint itself in the background. Make sure the messagebox is on top though.
|
|
|
|
|
|
I am trying to write then read my first XML file. It is meant to store settings for a device. The user will store stuff to the file, then maybe load it back and transmit it to the target board. Sounds pretty simple.
My question is how to parse this guy. How do I get the data back out so I can plop it on the forms I've created? I see how to rifle through the file, but now how the heck to see where I am. I'm very new to this, so a real-world example would be great.
Here's how I'm setting up to do the read.
StreamReader stream = new StreamReader(fi.FullName);
XmlTextReader reader = new XmlTextReader(stream);
XmlSchemaCollection schemaColl = new XmlSchemaCollection();
schemaColl.Add(null,"XMLSchema_LCData.xsd");
XmlValidatingReader valReader = new XmlValidatingReader(reader);
valReader.ValidationType = ValidationType.Schema;
valReader.Schemas.Add(schemaColl);
valReader.ValidationEventHandler += new ValidationEventHandler(valHandler);
while (valReader.Read())
{
// Now what? How would I know that I have some certain piece of data?
// Pretend I want to know that is the FINV0 for CreepB from the XML file.
}
Here's the XML file I am trying to parse:
<xmlschema_lcdata xmlns="http://tempuri.org/XMLSchema_LCData.xsd">
<datesaved>2/25/2005 1:51:54 PM
<softwarename>X-RES
<softwarepartnumber> 172814r
<softwareversion>0.1.0
<serialnumber>someCell
<partnumber>somenumber
<ad_configuration>
<roughcal>40.591
<tempgain>11.95457
<tempoffset>-884002
<tempoffset>16
<inputqr>40
<outputdecimator>1
<temperaturedecimator>8
<temperatureqr>10
<ad_runtime>
<retrainthreshold>120
<hysteresisthreshold>60
<noiserequirement>4
<openloopqr>255
<maxqr>70
<minqr>20
<systemtc>
<za>169666
<zb>0.01226807
<zc>-4.305039E-07
<sb>4.582489E-08
<sc>-5.763168E-13
<linearity>
<cor>1.255103E-10
<gain>0.9998779
<creep>
<creepa>
<finv0>6.496906E-05
<finv1>0
<finv2>0
<tau0>0.001777649
<tau1>0
<tau2>0
<creepb>
<finv0>4.994869E-05
<finv1>0
<finv2>0
<tau0>0.0001777411
<tau1>0
<tau2>0
<creepc>
<finv0>9.953976E-06
<finv1>0
<finv2>0
<tau0>5.924702E-05
<tau1>0
<tau2>0
<hysteresis>
<zero>119020
968630
<guardband>200
<increasing>
<a_term>0
<b_term>0
<c_term>0
<e_term>-1.065821E-12
<increasing>
<a_term>8E-05
<b_term>-8.259087E-11
<c_term>0
<e_term>-1.065821E-12
Any help?
Kenny O'Dell
Sr. R&D Software Engineer
Mettler-Toledo Inc.
Inman, SC
|
|
|
|
|
Sorry, didn't realize is was going to strip out the XML stuff. I'll try again.
I am trying to write then read my first XML file. It is meant to store settings for a device. The user will store stuff to the file, then maybe load it back and transmit it to the target board. Sounds pretty simple.
My question is how to parse this guy. How do I get the data back out so I can plop it on the forms I've created? I see how to rifle through the file, but now how the heck to see where I am. I'm very new to this, so a real-world example would be great.
Here's how I'm setting up to do the read.
StreamReader stream = new StreamReader(fi.FullName);
XmlTextReader reader = new XmlTextReader(stream);
XmlSchemaCollection schemaColl = new XmlSchemaCollection();
schemaColl.Add(null,"XMLSchema_LCData.xsd");
XmlValidatingReader valReader = new XmlValidatingReader(reader);
valReader.ValidationType = ValidationType.Schema;
valReader.Schemas.Add(schemaColl);
valReader.ValidationEventHandler += new ValidationEventHandler(valHandler);
while (valReader.Read())
{
// Now what? How would I know that I have some certain piece of data?
// Pretend I want to know that is the FINV0 for CreepB from the XML file.
}
Here's the XML file I am trying to parse:
<?xml version="1.0"?>
<XMLSchema_LCData xmlns="http://tempuri.org/XMLSchema_LCData.xsd">
<DateSaved>2/25/2005 1:51:54 PM</DateSaved>
<SoftwareName>X-RES</SoftwareName>
<SoftwarePartNumber> 172814r</SoftwarePartNumber>
<SoftwareVersion>0.1.0</SoftwareVersion>
<SerialNumber>someCell</SerialNumber>
<PartNumber>somenumber</PartNumber>
<AD_Configuration>
<RoughCal>40.591</RoughCal>
<TempGain>11.95457</TempGain>
<TempOffset>-884002</TempOffset>
<TempOffset>16</TempOffset>
<InputQR>40</InputQR>
<OutputDecimator>1</OutputDecimator>
<TemperatureDecimator>8</TemperatureDecimator>
<TemperatureQR>10</TemperatureQR>
</AD_Configuration>
<AD_Runtime>
<RetrainThreshold>120</RetrainThreshold>
<HysteresisThreshold>60</HysteresisThreshold>
<NoiseRequirement>4</NoiseRequirement>
<OpenLoopQR>255</OpenLoopQR>
<MaxQR>70</MaxQR>
<MinQR>20</MinQR>
</AD_Runtime>
<SystemTC>
<ZA>169666</ZA>
<ZB>0.01226807</ZB>
<ZC>-4.305039E-07</ZC>
<SB>4.582489E-08</SB>
<SC>-5.763168E-13</SC>
</SystemTC>
<Linearity>
<Cor>1.255103E-10</Cor>
<Gain>0.9998779</Gain>
</Linearity>
<Creep>
<CreepA>
<FinV0>6.496906E-05</FinV0>
<FinV1>0</FinV1>
<FinV2>0</FinV2>
<Tau0>0.001777649</Tau0>
<Tau1>0</Tau1>
<Tau2>0</Tau2>
</CreepA>
<CreepB>
<FinV0>4.994869E-05</FinV0>
<FinV1>0</FinV1>
<FinV2>0</FinV2>
<Tau0>0.0001777411</Tau0>
<Tau1>0</Tau1>
<Tau2>0</Tau2>
</CreepB>
<CreepC>
<FinV0>9.953976E-06</FinV0>
<FinV1>0</FinV1>
<FinV2>0</FinV2>
<Tau0>5.924702E-05</Tau0>
<Tau1>0</Tau1>
<Tau2>0</Tau2>
</CreepC>
</Creep>
<Hysteresis>
<Zero>119020</Zero>
<Span>968630</Span>
<GuardBand>200</GuardBand>
<Increasing>
<A_Term>0</A_Term>
<B_Term>0</B_Term>
<C_Term>0</C_Term>
<E_Term>-1.065821E-12</E_Term>
</Increasing>
<Increasing>
<A_Term>8E-05</A_Term>
<B_Term>-8.259087E-11</B_Term>
<C_Term>0</C_Term>
<E_Term>-1.065821E-12</E_Term>
</Increasing>
</Hysteresis>
</XMLSchema_LCData>
Any help?
Kenny O'Dell
Sr. R&D Software Engineer
Mettler-Toledo Inc.
Inman, SC
|
|
|
|
|
Use XmlDocument instead. Better performance for especially short XML files.
Here is an example:
<br />
private void Insert2XML(string strXmlFilePath, string PersonName, int ID, string Notes)<br />
{<br />
XmlDocument doc = new XmlDocument();<br />
doc.Load(strXmlFilePath);<br />
XmlNode root = doc.DocumentElement;<br />
<br />
XmlNode Person = doc.CreateElement("Person");<br />
Person.SetAttribute("Name", PersonName);<br />
Person.SetAttribute("ID", ID.ToString());<br />
Person.InnerText = Notes;<br />
root.AppendChild(Person);<br />
<br />
XmlTextWriter writer = new XmlTextWriter(strXmlFilePath, null);<br />
writer.Formatting = Formatting.Indented;<br />
writer.Indentation = 4;<br />
doc.Save(writer);<br />
writer.Close();<br />
}<br />
<br />
private string GetPersonID(string strXmlFilePath, string PersonName)<br />
{<br />
XmlDocument doc = new XmlDocument();<br />
doc.Load(strXmlFilePath);<br />
XmlNode root = doc.DocumentElement;<br />
<br />
XmlNode SearchNode = root.SelectSingleNode("//*[@Name='" + PersonName + "']");<br />
if (SearchNode != null)<br />
{<br />
return SearchNode.Attributes["ID"].Value;<br />
}<br />
else<br />
{return "Not Found!"}<br />
}<br />
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
The .NET TextBox control automatically provides a nice context menu that pops up when the user right-clicks in it with all the stuff expected, like Cut, Copy and Paste (and some surprising ones, like right-to-left selection, etc.). However, if you add a context menu component of your own you lose the one provided. Does anybody know a way to find and merge with the default menu? I've been trying to add an item to call a spell checker I've added to my project and don't want to have to duplicate all of the nice things the TextBox already provides on its default context menu... Any thoughts?
Thanks in advance for any help!
P.S. I posted this question in the .NET forum, too - I don't want to clutter up these boards with duplicates, but this area looked a bit more active so I thought I'd try here as well...
Mitchell
|
|
|
|
|
|
Thanks for the tip - I sure wish it could be easier, but at least you've given me a place to start!
Mitchell
|
|
|
|
|
I have a ListBox (CatList) and an ArrayList (Cats) bound to it. I'm removing the selected item in the ListBox from the ArrayList and rebinding the source after removing:
<br />
private ArrayList Cats = new ArrayList();
...<br />
...<br />
<br />
private void bRemoveCat_Click(object sender, System.EventArgs e)<br />
{<br />
int selIndex = this.CatList.SelectedIndex;<br />
<br />
this.CatList.DataSource = null;<br />
this.CatList.Items.Clear();<br />
<br />
Cats.RemoveAt(selIndex);<br />
<br />
this.CatList.DataSource = Cats;<br />
this.CatList.DisplayMember = "Name";<br />
this.CatList.ValueMember = "ID";<br />
}<br />
No exception is thrown when the above code is executed but after the code is executed, if I click on the ListBox, the exception below is immediately thrown.
<br />
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll<br />
<br />
Additional information: Index was out of range. Must be non-negative and less than the size of the collection.<br />
What do you think? Thanks in advance.
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
I'd verify the value of selIndex before you try and use it on the Cats arraylist.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I already did it Dave. Actually the item is removed properly. But the error occurs after this process (when I click anywhere on the ListBox)
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
Using ASP.NET with C# I have two login screens for the application. One to get into the system and a second login screen, which is for administrator tasks. The first one redirects me to my default page with the method below. I have duplicated the code from the login page and im using it for my admin login page but do not want it to automatically redirect me to the default screen again. Instead I would like it to direct me to a page called administrator.aspx. how do I do this. Im New to c sharp. Small hurdle huh! Any help much appreciated.
Chris
if (id != null)
{
// Set the user as authenticated and send him to the
// page originally requested.
FormsAuthentication.RedirectFromLoginPage(id, false);
}
|
|
|
|
|
Please direct your ASP.NET-related questions to the ASP.NET forum.
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, first of all try the ASP.NET forum as it would be more specified.
If my memory is correct, you can use the Response.
well for each aspx page there is HTTP support for REQUEST & RESPONSE.
you can use
this.response.redirect(...) method to redirect to another page.
Sorry, I don't know much asp.net.....but tried to help out anyway!
GaMBiT---> aND ReVeNGe WiLL Be
|
|
|
|
|
Thanks for your advice. will try it out
|
|
|
|
|
hi everybody
is any bod know how to run desktop application from we page...As specially on web page..?
|
|
|
|
|
Try the Web Development[^] forum, although you should keep in mind that you can't coax a browser into starting an application without exploiting a security hole because to do so would be a serious security vulnerability if it were allowed.
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,
I am relatively new to c# and i am working in .NET 2003. I use very often a MessageBox, but sometimes it comes without a text on it, even if i have assigned a text to it (MessageBox.Show(stringVariable); ). The same happens to ComboBox and ListBox. They appear blank, although they are bound to the corresponding DataSource. Later (when the application is still running) appears the text suddenly. May be does anyone know the problem?
Very gratefull in advance,
Sailer
|
|
|
|
|
Your description offers almost no technical information that is necessary to help you. Please provide snippets of your code, including your data-binding code (just snippets though, please). It's probably that if you're getting data from the underlying data source your not taking the appropriate actions to get the right data. Debugging your application and stepping through your code is what you should do first. In Visual Studio, just open your project, set a breakpoint at the beginning of a method that uses MessageBox where the problem occurs, and hit F5 (Debug->Start Debugging).
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]
|
|
|
|
|
Well a messagebox takes at least 2 parameters the caller and message,
Therefore I would suggest you to use it like this:
MessageBox.Show(this,StringVariable);
For the combobox & listbox, I would suggest you to loop through the datasource and insert an item every time! In this case, you can debug and it will be 1000% sure the items will be added!
Regards
GaMBiT---> aND ReVeNGe WiLL Be
|
|
|
|
|
Some people say that C# can't work with custom C++ interfaces. But at least I can see them in C# Object Browser.
Does anybody know the exact situation???
If C# does support custom interfaces how such type incompatibilities like byte[] and string can be handled???
Are there any botle necks???
Could it be faster using custom interfaces in C# instead of dispatch???
Vad
|
|
|
|
|
What do you mean by custom interfaces? C# classes can most definitely implement interfaces declared in C# that interop with native interfaces. I do it all the time, as COM interop is one of my fortés. You should start by reading Exposing .NET Framework Components to COM[^], since implementing a COM interface - if that is what you mean - would only make sense if you were trying to host your .NET Framework component in a COM client.
Strings and byte[] also marshal correctly and quite easily. Read Marshaling Data with COM Interop[^].
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]
|
|
|
|