I tried to count but in different way - it doesn`t work. Your way works great! Thanks a lot!
conrado7
Posts
-
Controlled Focus event - textBox -
Checking for valid XML file structureI need in my application to check if the data structure is correct in XML file which I read. How can I do that? Only message if it`s correct or not I need. Thanks
-
Controlled Focus event - textBoxI need leave my textBox control only if I press three times the Tab key. I use this:
private void KKEditControl_Leave(object sender, EventArgs e) { this.Focus(); }
but it keeps focus in my textBox all the time. Please help me... -
Formating text in textBoxI know what you mean, but it isn`t the action I want. I don`t want replace all characters in my textBox but I want replace only that character which is curently selected by the posision of the cursor. For example text: 12345 when the cursor is (for ex.) between 3 and 4 by enter new character a want replace character 4 by new one. This should work like insert key in Microsoft Word. Anyone know the answer?
-
Formating text in textBoxI want in my textBox enter characters in the following way:
private void textBox2_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { int i = this.textBox2.SelectionStart; if(i which is mean that every single character which is entered should replace existing character unless the cursor is on the end of the text. This sample code doesn`t work I want. Speaking gennerally I want in my text Box to replace all characters with new entered unless the cursor is on the end of the text. Can anyone help me? -- modified at 9:54 Wednesday 19th April, 2006
-
Editing an XML node in C#Maybe these piece of code will help you: 1) if you want create xml file with C# you can use example:
XmlDocument myXml = new XmlDocument(); string xml_text = ""+ ""+ ""+ ""+ ""+ ""+ ""; myXml.LoadXml(xml_text);
2) if you want open xml document use exmaple:XmlDocument myXml = new XmlDocument(); XmlTextReader reader = new XmlTextReader(file_name); myXml.Load(reader); reader.Close();
3) if you want save you xml document you can use example:XmlTextWriter writer = new XmlTextWriter("output.xml",null); writer.Formatting = Formatting.Indented; dokumentXml.Save(writer); writer.Close();
Best way to learn this is MSDN like http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vborixmlschemadesignerwalkthroughs.asp -
My user control (setting properties with my Properties window)I`ve just written my own user control which is inherited from RichTextBox control. This control has it own property called RegularExpression.
private string regularExpression; [Category("Behavior")] [Description("Wyrazenie regularne sprawdzające poprawność danych")] public string RegularExpression { get { return regularExpression; } set { regularExpression = value; } }
With this property I set up the regular expression which validates my data in control. My problem is that I want set up this property by clicking my control`s context menu (a new window form with textBox to set up regular expression in it) like in the picture: Click here... After clicking OK button I want to set up RegularExpression property with context in textBox. In main application in not a problem. The problem apprears when I want do this the way I,ve just described... I can`t create reference:private void okButton_Click(object sender, System.EventArgs e) ValidatingEditControl.KKEditControl.regularExpresson = this.regExpTextBox1.Text; }
It dispays: "ValidatingEditControl.KKEditControl.regularExpresson is inaccesible due to its protectionlevel". Can anyone help me with this? -- modified at 8:21 Monday 20th March, 2006 -
RichTextBox and SendKeys actionIt`s working :D Thank you very much :) But code
e.SuppressKeyPress = true;
I turned intoe.Handled = true;
:) -- modified at 9:50 Friday 17th March, 2006 -
Regular Expressions in C#I`ve been wondering about creating my own parser, but in more difficult RE it`s very hard to build it. For e.g. ^(/d{2}-/d{3}){3,}$ Reg Exp... How can my parser read this to show me wich character is invalid? Any ideas?
-
RichTextBox and SendKeys actionDoes anyone of you can tell why the following code:
private void HandleKeyPress(object sender, KeyPressEventArgs e) { char c = e.KeyChar; if(c == (short)Keys.Back) { e.Handled = true; SendKeys.Send("{LEFT}"); return; } }
works in common textBox but it doesn`t work in richTextBox? In textBox linee.Handled = true;
stops the backspace key action and only action after pressing bakcspace key is move the cursor to left (SendKeys.Send("{LEFT}");
). In richTextBox it`s taken double action.e.Handled = true;
code doesn`t block backspace key action so: 1) first it deletes character (backspace key do it - it isn`t block) 2) second it moves the cursor to left (likeSendKeys.Send("{LEFT}");
code do) Can anyone figure out what`s wrong with it? -
Regular Expressions in C#You sugested that in a more difficult regular expression the better thing to do is to write my own regular expression parser? Do you have any idea how I suppose to do this?
-
Regular Expressions in C#Are you absolutely sure? Anyway...Thank you very much... You let me safe so much time of my research...
-
Regular Expressions in C#Does anyone of you can answer to my question? I want use regular expression in my text box to validate text. For example reg. expression like this : "[0-9][0-9]-[0-9][0-9][0-9]" accepts only for example "43-456" text. What if I enter "54-8f5" ? .NET Regular Expressions tells me that this text is not correct. But it doesn`t tell me which character is invalid. My problem is that I want .NET Regular Expressions show me which character (which character index in this incorrect string) is invalid. Please help me... -- modified at 15:53 Thursday 16th March, 2006 Is it possible with .NET regular expressions?
-
read imageYou can use this code:
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Graphisc g = e.Graphisc; Bitmap bmp = new Bitmap("your_image.jpg"); g.DrawImage(bmp, 0, 0); }
-- modified at 9:27 Thursday 16th March, 2006 -
New window in applicationThanks a lot :) I discovered that code:
System.Windows.Forms.Form NewFormObject = new MyForm();
is valid too :) -
New window in applicationHow to invoke from From1 application (it`s the main appliction) to another form (window) with for example cliking the button?
-
SendKeys in C#You asked me why it doesn`t work. It takes two action in the same time. First it deletes charakters (so backspace key works like should work), second it moves cursor to left like I want. In textBox works only second action which exactly I want. In richTextBox work both of them.
e.Handled = true;
code should make a backspace key action not allowed. Why is that? I need this action in my richTextBox to validate text which I enter to this. -
SendKeys in C#I want in my RichTextBox this action to do: Backspace key takes the same action like left arrow key. Speaking generally I don`t want to delete characters by backspace key inside the textBox field unless it is the last character. This code works in TextBox (do the action which I want) but unfortunatelly doesn`t work in RichTextBox.
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { char c = e.KeyChar; int start = textBox1.SelectionStart; int lenght = textBox1.Text.Length; if(c == (short)Keys.Back && start!=lenght) { e.Handled = true; SendKeys.Send("{LEFT}"); return; } }
Can anyone help me? -
"SendKeys" in TextBox and RichTextBox (C#)I want in my RichTextBox this action to do: Backspace key takes the same action like left arrow key. Speaking generally I don`t want to delete characters by backspace key inside the textBox field unless it is the last character. This code works in TextBox (do the action which I want) but unfortunatelly doesn`t work in RichTextBox.
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { char c = e.KeyChar; int start = textBox1.SelectionStart; int lenght = textBox1.Text.Length; if(c == (short)Keys.Back && start!=lenght) { e.Handled = true; SendKeys.Send("{LEFT}"); return; } }
Can anyone help me? Sorry for my english ;) -
Regular Expressions in .NET (C#)Can anyone help me? I`ve just started my adventure with .NET. I want use regular expression in my text box to validate text. For example reg. expression like this : "[0-9][0-9]-[0-9][0-9][0-9]" accepts only for example "43-456" text. What if I enter "54-8f5" ? .NET Regular Expressions tells me that this text is not correct. But it doesn`t tell me which character is invalid. My problem is that I want .NET Regular Expressions show me which character (which character index in this incorrect string) is invalid. Can anyone help with this? conrados