|
Thanks for help. Can You tell me where can i read about this way of xml ? Read all Xml related articles ?
One nation - underground
|
|
|
|
|
Saikek wrote: Can You tell me where can i read about this way of xml ?
Here?[^]
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
|
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|
|
I just want to numeral.So I want to hold up any keys except numeral keys.
But I must not use NumericUpDown Control.
My code snippet:
switch (e.KeyCode)
{
case Keys.D0:
case Keys.D1:
case Keys.D2:
case Keys.D3:
case Keys.D4:
case Keys.D5:
case Keys.D6:
case Keys.D7:
case Keys.D8:
case Keys.D9:
case Keys.NumPad0:
case Keys.NumPad1:
case Keys.NumPad2:
case Keys.NumPad3:
case Keys.NumPad4:
case Keys.NumPad5:
case Keys.NumPad6:
case Keys.NumPad7:
case Keys.NumPad8:
case Keys.NumPad9:
break;
case Keys.Enter:
this.btnOK.Focus();
break;
default:
//hold up
break;
}
I do not know how write code at default.
please give me directions or other scheme ,thanks.
|
|
|
|
|
Hello,
I assume that you are handling the KeyDown event, and you whant to prevent non numerical inputs!
Then you have to set:
e.Handled = true;
Hope it helps!
All the best,
Martin
|
|
|
|
|
I writed
"e.Handled = true"
But it is noneffective.
it is anticly.
|
|
|
|
|
Hello,
jason_mf wrote: But it is noneffective.
YEs, sorry you also have to handle KeyPress!
But what I would recommend is inheriting your own NumericTextBox from TextBox.
public class NumericTextBox : System.Windows.Forms.TextBox
{
And override OnKeyPressed and OnKeyDown:
bool keydownHandled;
protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.D0:
case Keys.D1:
case Keys.D2:
case Keys.D3:
case Keys.D4:
case Keys.D5:
case Keys.D6:
case Keys.D7:
case Keys.D8:
case Keys.D9:
case Keys.NumPad0:
case Keys.NumPad1:
case Keys.NumPad2:
case Keys.NumPad3:
case Keys.NumPad4:
case Keys.NumPad5:
case Keys.NumPad6:
case Keys.NumPad7:
case Keys.NumPad8:
case Keys.NumPad9:
case Keys.Enter:
break;
default:
e.Handled = true;
break;
}
keydownHandled = e.Handled;
base.OnKeyDown (e);
}
protected override void OnKeyPress(KeyPressEventArgs e)
{
e.Handled = keydownHandled;
base.OnKeyPress (e);
}
For the ENTER Key you can do the handling of KeyDown directly on the Form.
Hope it helps!
P.S.: Don't forget to care about "copy/paste"
All the best,
Martin
|
|
|
|
|
Hello,
An other way to validate the KeyPress for numeric input is:
const string validinput = "1234567890";
protected override void OnKeyPress(KeyPressEventArgs e)
{
if (validinput.IndexOf(e.KeyChar) < 0)
{
e.Handled = true;
}
base.OnKeyPress (e);
}
All the best,
Martin
|
|
|
|
|
Here's my solution. Any comments are welcomed.
static bool isIISContainsCert() {
try {
DirectoryEntry W3C = new DirectoryEntry("IIS://Localhost/W3SVC");
foreach(DirectoryEntry entry in W3C.Children) {
PropertyCollection props = entry.Properties;
if( props["KeyType"].Value.ToString() == "IIsWebServer"
&& props["SSLCertHash"].Value != null ) {
return true;
}
}
} catch (Exception e) {
GTools.Logger.FileLog(e.ToString());
}
return false;
}
|
|
|
|
|
I have an arraylist that contains objects who themselves contain multiple properties. I would like to know is there are faster way than using a for loop to search through an arraylist to find the object whose certain property matches what I am looking for. An example of what I am currently doing is listed below.
for(int p = 0; p < SupplierItemDataStore.Count; p++)
{
if(stock.Code == ((XMLDefs.SupplierItem.SupplierItem)SupplierItemDataStore[p]).StockCode)
{
{
//Do stuff here
}
}
}
where stock is the object that is passed in and SupplierItemDataStore contains over 31,000 items.
|
|
|
|
|
I don't think that there will be more faster way.
<br />
foreach(XMLDefs.SupplierItem.SupplierItem sItem in SupplierItemDataStore){<br />
if(stock.Code = sItem.StockCode){<br />
}<br />
}<br />
There are a lot of C# gurus in our forum.. let's see what they say..
|
|
|
|
|
If you put the data in a HashTable with the stock code as key, you can locate the item very quickly.
If you use framework 2.0 you would use a Dictionary instead of a HashTable.
---
single minded; short sighted; long gone;
|
|
|
|
|
>>If you put the data in a HashTable with the stock code as key, you can locate the item very quickly.
Yeah. Great Idea. Thanks..
|
|
|
|
|
Thanks for your help guys. The hash table is the way I'm going to have to go as the application I'm developing is on Framework 1.1 so I can't use a Dictionary.
|
|
|
|
|
Hello friends,
i have one problem, i have one table control in that table control i took 5 radiobuttons. below table control i have 2 text boxes.
totally 33 qns , upto 31 i want radio button after 31 i want textboxes inplace of radion buttons.
please give me one idea, how can i adjust this design.
please urgent......................
srinivas
|
|
|
|
|
Still the online test/quiz?
Place your radio buttons and text boxes on the form as you would usually do. Set the textboxes' Visible property to false.
When you reach the 32nd question, set the radio buttons' Visible property to true and the textboxes' Visible property to true.
Cheers,
Vıkram.
After all is said and done, much is said and little is done.
|
|
|
|
|
hi all,
i have a list view and lisviewitems in this listview , now when i right click on any lisviewitem it getting selected , i don't want to select it with right click , i just want to select itwith left click.How can i cancel the event when it's right click coz there is no cancel in MouseEventArgs.
please help me.
thanx.
Praveen Sharma
|
|
|
|
|
in my C# program,i input "at" in a textBox,then the program send "at" to serialport,but when i click receive button,the message I receive from serial port is the same as what I input,namely "at",not "ok",why?who can answer my question?How I solve this problem and get the right response "ok" from serial port?
next is my code:
public partial class Form1 : Form
{
private SerialPort sp = null;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
sp = new SerialPort("COM1");
sp.ReadTimeout = 5000;
sp.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button2_Click(object sender, EventArgs e)
{
try
{
sp.Write(textBox1.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button3_Click(object sender, EventArgs e)
{
try
{
/*string text=null;
char[] buffer = new char[10];
sp.Read(buffer,0,6);
for (int i = 0; i < buffer.Length; i++)
{
text += buffer[i];
}
textBox2.Text = text;*/
/*string text = null;
char t = (char)sp.ReadChar();
text+=t.ToString();
while (true)
{
t = (char)sp.ReadChar();
if (t == '\0') break;
else text += t.ToString();
}
textBox2.Text = text;*/
string text = null;
byte[] t = new byte[20];
char[] c = new char[20];
sp.Read(t, 0, t.Length);
sp.Read(t, 0, t.Length);
c = Encoding.ASCII.GetChars(t);
int i;
for (i = 0; i < c.Length; i++)
{
if (c[i] == 'O' || c[i] == 'K')
text += c[i].ToString();
}
textBox2.Text = text;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
|
|
|
|
|
|
if the end result is not what you want it is wise to look at the intermediate data,
in your case log the bytes that the serial port returns to you (I would use HEX numbers).
If they are exactly what you have sent, then either your target device is echoing them,
or you have an unintended connection between TxD and RxD (transmit data and receive data)
on your serial cable.
|
|
|
|
|
Hello,
how can i display the hex values for each byte of a sting in a richtextbox?
thanks!
|
|
|
|
|
Hello,
roiter wrote: for each byte of a sting
I don't understand this!
But maybe you are searching for this:
string HexText= String.Format("{0:X}", value);
Hope it helps!
All the best,
Martin
|
|
|
|
|
thank you! i will try it later.
I am knew in C#. in C there is no datatype string, you can define a byte array and use it as a string. So each byte is manipulateable by indexing.
|
|
|
|
|
Wellcome
All the best,
Martin
|
|
|
|