|
The way you are doing it now is not a bad way to do it. The problem you had before has to do with the parameters you were passing. It was looking for a string and an image and you were passing a string and a delegate.
The only thing that I would change is don't make an image object for no reason, just set it to null:
ToolStripMenuItem mv = new ToolStripMenuItem(w.Name, null, new System.EventHandler(OnChange));
That will save a little time and memory.
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
|
|
|
|
|
Thank you for your reply.
You are absolutely right though. What you've shown me is a much better way of doing. Basically we're doing the same thing, however your way is more elegant.
Thank you so much again !
|
|
|
|
|
hi
i want to use regular expression to ignore some characters in string that i want to search within it, but i don't found good tutorial for this topic(regular expression).
can anyone guide me for it and special characters for regular expressions like $,*,\\d, .... ?
thanks
|
|
|
|
|
|
I keep this[^] page bookmarked for these types of questions
|
|
|
|
|
hello,
i have 5 checkboxes in the form, i want to do something like this:
<br />
foreach (control c in this.Cotrols)<br />
{<br />
if (c.GetType.ToString() == "System.Forms.CheckBox")<br />
{<br />
MessageBox.Show("anything"); <br />
}<br />
}<br />
the problem is:
if the checkboxes are inside a panel, ou a groupbox, i cant verify if exists checkboxes in the form...
what i can do to find the checboxes that are inside de panel/groupbox?
thanks a lot
|
|
|
|
|
Controls can have child controls of their own. If you know the checkboxes are in a group or on a panel, all you have to do is look in the Controls collection of that container control.
Also, don't EVER convert the type name to a string and compare it to what you think the full type name should be. You'll just end up writing code where you can't fathom what wrong with it.
foreach (control c in Panel1.Controls)
if (c is CheckBox)
...
|
|
|
|
|
foreach (control c in Panel.Cotrols)
{
if (c.GetType.ToString() == "System.Forms.CheckBox")
{
MessageBox.Show("anything");
}
}
only two letters away from being an asset
|
|
|
|
|
check the type of c and if it is a panel use the c.Controls to itenerate through it's children.
-- modified at 16:21 Monday 21st May, 2007
topcoderjax
|
|
|
|
|
Recurse the controls as a tree.
Call seekCheck pasing the form as first control.
private void seekCheck (Control B)
{
foreach(Control Con in B.Controls)
{
if(Con.Controls != null) //is a container
{
seekCheck (Con);
}
else
{
if(Con id CheckBox)
{
MessageBox (".....");
}
}
}
}
|
|
|
|
|
Fernando Jaspion wrote: if (c.GetType.ToString() == "System.Forms.CheckBox")
You don't want to do a string compare here. What you want is:
if (c.GetType() == typeof(System.Forms.CheckBox);
Ian
|
|
|
|
|
no no, just
if (c is CheckBox) ...
|
|
|
|
|
right you are!
Ian
|
|
|
|
|
Hello,
I mostely prefere to cast direct to the class I'm checking on, cause often a member of this class is on interest.
CheckBox cb = c as CheckBox;
if(cb!=null)
A recursive method would check the "Controls" property of the Control instance c.
RecursiveMethod(this.Controls);
private void RecursiveMethod(ControlsCollection cc)
{
if(cc!=null)
{
foreach(Control c in cc)
{
CheckBox cb = c as CheckBox;
if(cb!=null)
{
}
else
{
RecursiveMethod(c.Controls);
}
}
}
}
Hope it helps!
All the best,
Martin
|
|
|
|
|
I want to use other name of class for example:
this is a simple class:
class Myclass
{
private int _No;
public Myclass()
{
}
public int No
{
get{return _No;}
}
}
I want to use other name a new name (Nocc) for Myclass
Nocc N1=new Nocc();
N1.No=91;
|
|
|
|
|
Your Myclass doesn't have another name. Where did this Nocc thing come from?
|
|
|
|
|
first thank you for reply
Nocc is the new name i want to use it Like Myclass
i do not know what's the command to do something like this
thanks in advance,
|
|
|
|
|
A class cannot have two names. To use the Nocc name all you'd have to do is replace MyClass with Nocc in the class definition.
|
|
|
|
|
class Nocc
{
#region Variables
private int _no;
#endregion
#region Constructors
public Nocc()
{
}
#endregion
#region Properties
public int No
{
get {return (_no);}
set {_no = value;}
}
#endregion
}
I have no idea what your asking for... I just like #regions
|
|
|
|
|
irishdunn wrote: I have no idea what your asking for
I think he means aliasis. Like String and string. System.Int32 and int
|
|
|
|
|
Giorgi Dalakishvili wrote: I think he means aliasis. Like String and string. System.Int32 and int
Oh then:
using Nocc = MyClass;
// then in code:
Nocc mything = new Nocc();
// etc
led mike
|
|
|
|
|
I am trying to bind a control to this dataset and have been successful thus far, problem is I want to be able to specify the row in the table the control is binding to. Apologize for any ineptitudes in advanced, very new to this.
sample:
newTBox.DataBindings.Add("Text", _Data, _tableName + "." + field, false);
I want to do something like this:
newTBox.DataBindings.Add("Text", _Data, _tableName + "[" + _rowNumber + "]" + "." + field, false);
right now it is always binding to the 0th row in my table.
Thanks in advance
|
|
|
|
|
Can U use a filtered select query or view instead of the table as data source?
|
|
|
|
|
No I am working with a supplied dataset, so I will have to navigate through it properly.
I am trying now to get something like this to work:
("Checked", Data.Tables[_tableName].Rows[_rowIndex], field, false);
don't think thats gonna hack it though
help!
|
|
|
|
|
Still cant figure this out
here is my poopy code:
newTBox.DataBindings.Add("Text", _Data.Tables[_tableName].Rows[_rowIndex],
_tableName + "." + field, false);
|
|
|
|