|
Personally I would have illustrated it differently, mainly by building up a List<TextBox> inside the recursive method.... but your example shows the main ingredients
-- modified at 10:41 Monday 30th July, 2007
|
|
|
|
|
Hello,
J4amieC wrote: but your example shows tyhe main ingredients
Actually, if I have to find out all the members of a type, I mostly hold the references in an ArrayList(.Net1.1) for further usage.
But it really depends on the task.
If he is only searching for one special TextBox instance which is somehow marked (over the Tag property for example), then there is no need for holding all the references, I guess.
All the best,
Martin
|
|
|
|
|
Martin# wrote: If he is only searching for one special TextBox instance which is somehow marked (over the Tag property for example), then there is no need for holding all the references, I guess.
Indeed. Hadn't thought of that!
|
|
|
|
|
Although Martin# has given you a great answer above, remember that Controls are in a heirachy which means that Textboxes could be inside a Panel on the main form, so you might need some kind of recursive function to determine all textboxes on a form
|
|
|
|
|
for(int i=0;i < this.Controls.Count; i++)
{
if(this.Controls[i].GetType() == typeof(System.Windows.Forms.TextBox))
{
MessageBox.Show("textbox");
}
}
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
This code snippet will not find controls based on TextBox;
which "is TextBox" or "as TextBox" do.
|
|
|
|
|
could you please explain it more for me ??
thank you
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
this.Controls[i].GetType() == typeof(System.Windows.Forms.TextBox)
This will not be true for a class descendant of TextBox, that's why.
Standards are great! Everybody should have one!
|
|
|
|
|
thank you very much
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
Hi all, i am trying to delete a row from dataset ,i have used the following code but i am getting error like
An unhandled exception of type 'System.InvalidOperationException' occurred in mscorlib.dll
Additional information: Collection was modified; enumeration operation may not execute.
foreach(DataRow dreach in MailDataset.Tables[0].Rows)
{
if(Convert.ToInt16(dreach["Mailid"])== 37)
{
dreach.Delete();
MailDataset.AcceptChanges();
MailDataset=MailDataset ;
sd1=MailDataset.Tables[0].Rows.Count;
//Da.Update(MailDataset);
}
}
|
|
|
|
|
|
Hi Deepak Kumar
The url send by you is used to delete a row from hash table but my requirement is that i need to delete a row from dataset
Thnaks in Advanc
Gupta
|
|
|
|
|
You often cannot delete items from a collection that you're doing a foreach on. I usually build a list of items to delete, then iterate over that list, to do the deleting.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello all,
trying to write a console application that will act as a network bridge between 2 network adapters. This means i need to pass everything from 1 adapter to the other both ways. The names of the adapters is known,
Would appreciate any help,
Amir.
|
|
|
|
|
IIRC you can bridge in the Network Connections window, no code required.
|
|
|
|
|
I know i can do so through network connection window but i need to do it through code...
|
|
|
|
|
You will get some hits when searching CP for "network sniffer" or something similar.
|
|
|
|
|
I have a console application spanning multiple methods and functions, and based on a flag value I wish to abort program execution.
Is there any other method other than break(which cannot be used always)?
Thanks!
h.
|
|
|
|
|
You basically want something like this, I can't help more without knowing more.
static bool abort;
static void Main(string[] args)
{
while (!abort)
{
DoStuff();
}
}
|
|
|
|
|
Have you tried Environment.Exit() ? It worked for me
|
|
|
|
|
Thanks. Environment.Exit() works. I was not aware this function.
|
|
|
|
|
Environment.Exit() not working for you?
|
|
|
|
|
|
I am creating a custom control like listbox. So I need to implement CollectionProperty which will open collection editor to add the items at the design time. I succeeded in creating collectionclass and item class. But I am not able to set this to property. It shows (collection) in the property. But when I open collection editor and add new item, it is showing System.Object . I am not able to get my item class properties there. Could any one point me to the right direction to implement collection properties. Any urls' also will be helpful.
|
|
|
|
|
You need an indexer (aka Item) that sets and gets the Type. Also the Type, needs a default constructor.
|
|
|
|