|
Hi again,
by that I get the just entered char but and to check the total value I have the merge the already entered value and the just entered concidering position also.
But for a very short time before the value out of range is set to Max/Min you get to see the total value added. Can't I get it somehow?
Regards,
TooDoo
|
|
|
|
|
OK, then move the KeyPress code to the Validating Event and alter the following:
if ( Int16.TryParse( textBox1.Text.Trim() + e.KeyChar.ToString(), out num ) ) {
TO
if ( Int16.TryParse( textBox1.Text.Trim(), out num ) ) {
Make sure take the Textbox Property CausesValidation = true;
I'm listening but I only speak GEEK.
|
|
|
|
|
Dear All,
I want to add menuitems at run-time. If I use a menu, I can use the following method :
menuItemFile.MenuItems.Add(0, new System.Windows.Forms.MenuItem("-"));<br />
foreach (FileInfo XmlDescriptorFile in XmlDescriptorFiles)<br />
{<br />
try<br />
{<br />
blah blah ...
Is there a way to do exactly the same thing with a MenuStrip ?
Cheers,
|
|
|
|
|
DropDownItems.Add(...)
led mike
|
|
|
|
|
I can't for the life of me get this to work. My internet crawl has produced nothing.
Executing this code:
<br />
using (StreamReader sr = new StreamReader(f+"\\CDINDEX.txt"))<br />
{<br />
string line;<br />
<br />
while ((line = sr.ReadLine()) != null)<br />
{<br />
Console.WriteLine(line);<br />
}<br />
}<br />
I get the following exception: " The given path's format is not supported."
Using a messagebox the path clearly reads: "c:\test\CDINDEX.txt" which is the correct and true path to the file.
Can anyone help me as to why for some reason Microsoft decided today not to like me?
Thanks.
|
|
|
|
|
Lordveralix wrote: using (StreamReader sr = new StreamReader(f+"\\CDINDEX.txt"))
go with
using (StreamReader sr = new StreamReader(f+"\CDINDEX.txt"))
Hope it is the error.
Regards,
Satips.
|
|
|
|
|
The reason \\ is used is because \ denotes an escape sequence like \t or \n. A double slash \\ allows a slash. Using just \CDINDEX.txt returns an error for invalid escape.
|
|
|
|
|
There's a bunch of useful methods in System.IO.Path to make sure your path is correct. I'd use Path.Combine() just to be sure in this case...
Standards are great! Everybody should have one!
|
|
|
|
|
Try
string MyPath = f+"\\CDINDEX.txt";
Put a break after this and look at the value of MyPath. I would hope there would be some obvious error, but if not then copy the value and put it in the command prompt and make sure it works.
topcoderjax
|
|
|
|
|
What is f?
Could you quickly try
<br />
using (StreamReader sr = new StreamReader("C:\\test\\CDINDEX.txt"))<br />
instead?
Arti
|
|
|
|
|
Like Bekjong said, the correct way to put a path together would be to use the Path class and it's Combine method:
string filepath = Path.Combine(f, @"CDINDEX.txt");
using (StreamReader sr = new StreamReader(filepath)
|
|
|
|
|
I have added a group of controls to a form using code and added the controls to the form collection.
How can I later iterate through all of the controls on the form and drop the (Textbox) controls that I added earlier?
I can use a property in the control to do the ID, but I need code to iterate through all controls, and to drop selected controls.
A code sample would be great!
Joseph Stanish
|
|
|
|
|
The easiest way to remove a control is to keep the reference from when you created it, and use use the Remove method:
SomeParent.Controls.Remove(SomeTextbox);
---
single minded; short sighted; long gone;
|
|
|
|
|
(I guess I could dim a collection of textboxes and add each of my textbox controls to this collection, and then when it is time to remove these controls go throught this collection and drop the controls form the form ...
Is the correct?
That sounds like a very good idea! Could you please provide a brief code sample?
Joseph Stanish
|
|
|
|
|
What's so hard about iterating through your controls? If you can add the pro grammatically it's just as easy to remove them, isn't it?
this.SuspendLayout();
Collection<Control> temp = new Collection<Control>();
foreach (Control c in this.Controls)
{
if (c.GetType() == typeof(TextBox) && c.Tag == "drop me")
{
temp.Add(c);
}
}
foreach (Control c in temp)
{
this.Controls.Remove(c);
c.Dispose();
}
temp = null;
this.ResumeLayout();
Standards are great! Everybody should have one!
|
|
|
|
|
Perfect. Thanks.
Joseph Stanish
|
|
|
|
|
Hello,
Very nice idea to copy the instances in a seperate Collection instead of Cloning the Collection!
Never thought of this bevor!
Thanks for that!
All the best,
Martin
|
|
|
|
|
Bekjong wrote: if (c.GetType() == typeof(TextBox)
or better yet
if (c is TextBox && ... )
|
|
|
|
|
Umm. Iterate through the Controls collection of the Form and set the Parent to null for the control you want removed from the form.
Marc
Thyme In The CountryInteracxPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
I need a code sample
Joseph Stanish
|
|
|
|
|
Maybe a "please" would help!
|
|
|
|
|
here you are ... "Please"
by the way, you do not need to reply; instead of searching the form, I am going to keep a list of added controls, I will then iterate through my own list to drop the correct controls.
Thanks.
Joseph Stanish
|
|
|
|
|
Hello,
Joseph Stanish wrote: here you are ... "Please"
by the way, you do not need to reply
No need to be ironic and/or rude!
Joseph Stanish wrote: instead of searching the form, I am going to keep a list of added controls, I will then iterate through my own list to drop the correct controls.
Thats a very good Idea!
I would use an ArrayList to hold the instances of the TextBoxes.
I would also be carefull, when iterating over an Collection and Removing an item out of this Collection.
For that, I would Clone the ArrayList and iterate over the Clone, cast each object to TextBox (with "as"), do my validation, and remove it from the original Collection!
All the best,
Martin
|
|
|
|
|
Joseph Stanish wrote: I need a code sample
Seriously, if you can't write:
foreach(Control ctrl in form.Controls)
{
if (ctrl.Tag==myTag)
{
ctrl.Parent=null;
break;
}
}
Then I have to ask, what are you doing pretending to be a programmer?
Marc
Thyme In The CountryInteracxPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
Hi,
I am writing the user control,inside user control i am adding button
control. I have collection of buttons,button is geting added using property editor. I want user should not be able to move the button at design time (when user drops my user control on the Form)
I tried with Locked property of button but we can not set this property at run time.
How should i avoid the user to move the button??
Thanks,
Tushar
|
|
|
|