|
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.
|
|
|
|
|
Thanks, Could you please show me a some sample code or article where I can find more information on this ?
|
|
|
|
|
Hello,
N a v a n e e t h wrote: I succeeded in creating collectionclass
I guess like that:
public class YourItemsCollection : CollectionBase, IDisposable
{
}
For this class you have to write an converter, which inherits from "System.ComponentModel.ExpandableObjectConverter".
public class YourItemsCollectionConverter: ExpandableObjectConverter
{
}
In this class you have to override following methods:
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] filter)
The "YourItemsCollectionConverter" has to be set as an Attribute to "YourItemsCollection":
[TypeConverter(typeof(YourItemsCollectionConverter))]
This article[^] shows it very good!
-- modified at 8:18 Monday 30th July, 2007
-- modified at 8:34 Monday 30th July, 2007
All the best,
Martin
|
|
|
|