|
Maybe set the timer to run for 5000 milliseconds and then have the thread terminate? Just a quick thought
|
|
|
|
|
|
hi,
thanks..
You have gave me an idea to implement it;)
|
|
|
|
|
Have a sample.xml with ten lines. Iam looking for the 3rd line or the line with the tags <system>.
how can I read what is between a tag, for example
<system>unknown
I tried this code
******************
XmlTextReader reader = new XmlTextReader ("c:\\sample.xml");
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Text:
listBox1.Items.Add(reader.Value);
break;
*************************
but it list all of the values
thanX in advanced
|
|
|
|
|
The message supposed to read with the tags "SYSTEM"
for example "<system1>"unknown""
|
|
|
|
|
You'd need to post the XML, but, broadly, you should not read XML by counting lines, but by using XPath ( there's a clue, go and google XPath ).
The XmlDocument class is what you want to use to search Xml documents.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
use XmlDocument...
XmlDocument xd= new XmlDocument();
xd.load(@"x:\x.xml");
// then
xd.getElementsByTagName();
any thing u can do....
|
|
|
|
|
Hi there! I've an application in which I use Microsoft Office Document Imaging component to read scanned files(tiff format). Sometimes file can not be read by OCR so exception occurs I've put that block in try-catch block. Now to the real problem which does not occur always and on all the files or on all the systems. Sometimes while reading the tiff files "Object reference not set to an instance of an object" problem occurs. Bigger problem is that it does not occur in debugging mode but while testing the exe. My most of the code is inside try-catch block. So my question is can I trace error like inside a web appication(Application_onError) and trace the exact point where error occurs. Any help would be higly appreciated.
Thanks in advance.
Don't Quit
|
|
|
|
|
I am new to programing in general and I am doing my best to learn C#. In working on my current self invented project i have ran into a problem, I need to control what characters can be entered in a text box. I want to only allow the # 1-9 if that helps. thanks in advance for any suggestions.
|
|
|
|
|
This is a common question, but the solution is a little complex, at least for a beginner. The answer is to handle the KeyPress event for the control, and to check if the key is what you want, or to reject it. Setting Handled to true on the event args rejects the keypress, so the code is something like:
e.Handled = ! ( Char.IsNumeric(e.KeyChar) || Char.IsControl(e.KeyChar));
No warranty expressed or implied on the above line, it's a guess
Or you can use a masked edit control.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Thank you, Makes sense however i get this message when i input the code... System.EventArgs' does not contain a definition for 'Handled' once again i am sure this would be something easily fixed by someone with moderate experience. Any help would be appreciated
|
|
|
|
|
EventArgs is a base class, the KeyPressed event gets passed KeyPressedEventArgs. I may be wrong it may be the KeyUp event that you need to handle.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
i added the EventArgs class, It didn't do anything. So i need to define "handled"
this
e.Handled = ! ( Char.IsNumeric(e.KeyChar) || Char.IsControl(e.KeyChar));
I'm terribly confused, but the good news that generally happens right before i begin to understand everything. So in this case what is "Handled" a method field or a constructor? and what do u recommend i do about defining it?
-- modified at 22:51 Friday 2nd February, 2007
Ok never mind i need to place this code inside a method thats tied to an event but the same problem still exists and im not all that sure of how to write that method.
|
|
|
|
|
You should use the KeyPress event; the KeyPressEventArgs has a "Handled" member
that you can set true for characters (not arbitrary keys) that you want to refuse.
Luc Pattyn
|
|
|
|
|
HAndled is a property on the KeyPressedEventArgs object, which is passed into an event handler for the key press event. If you get click on your textbox int he designer, click the lightning on the properties window, go down to 'KeyPress' and type in 'OnKeyPress', you'll get the method that needs the above code.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
almost works but i get this message
c:\Visual C# Step by Step\Chapter 1\Suduko1.1\Form1.cs(3223): 'char' does not contain a definition for 'IsNumeric'
any suggestions
|
|
|
|
|
maybe it's Char ? Or maybe it's char.IsNumber
It's char.IsNumber. Intellisense is your friend....
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi ,
For my windows app, i stored my connection in application settings i.e. project > properties> settings tab.
Now i need to access the connection string from code
any help is appreciated,
yojimbo
|
|
|
|
|
I'm trying to create a structure that contains an array of another structure within it and keep getting compile errors: Here's what I'm trying to do:
public struct MyState
{
int Id;
byte state;
}
// This gives me a compile error - cannot have instance field initializers in struct
public struct MyArray
{
MyState[] state = new MyState(100);
}
so I tried this - Gives me a compile error also
// fixed size buffer must be one of the following int, bool, etc...
public struct MyArray
{
fixed MyState state[100];
}
Any ideas - I'm receiving a message from a legacy system that has the message format wired to a specific byte layout.
Kim
Kim Ferrari
|
|
|
|
|
MyState[] state;
is an array reference; it will start life with the value null ( compare to TextBox tb; )
You can assign something to it with code within a method, or as an initializer if
it is a member of a class, but not in a member of a struct (struct members dont take
an initializer)
In a struct, you should use a constructor if you need some data to be initialized inside
the definition of the struct.
So you could write:
public struct MyArray {
MyState[] state;
public MyArray() {
state = new MyState[100];
}
}
and there are some variations, you could get the size as a parameter in the constructor,
or you could create (=call new) the array at a later point in time, i.e. within the
code that uses your MyArray.
Luc Pattyn
|
|
|
|
|
Thanks!
Kim
Kim Ferrari
|
|
|
|
|
Hi,
I'm trying too add MouseClick event or any event on WIA video stream overlay.
WIA video is previewed in window form which has registered events. But events aren't triggered when mouse is over WIA video overlay.
Overlay is previewed in the form like this:
wiaVideo = new WiaVideoClass();
wiaVideo.CreateVideoByWiaDevID( wiaDeviceID, window.Handle, 0, 1 );
How can I catch MouseClick Event over wiaVideo?
Thanks
|
|
|
|
|
If your WiaVideoClass has an Enabled property and your app functionality allows it, try
setting it false, so the mouse events go to the underlying control.
Luc Pattyn
|
|
|
|
|
Thanks for the quick answer,
but WiaVideoClass does not have Enabled property. I'm wondering is this possible to do without any involvement of WIA object (just by using underlying control)?
|
|
|
|
|
OK.
Please tell more about WiaVideoClass (purpose, origin, source available, does it need
user interaction, etc).
Luc Pattyn
|
|
|
|