|
foreach(Control c in Controls)
{
Label l = c as Label;
if (l != null) l.Text = "";
}
Remember, C# is case sensitive.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Would you also use this?
foreach(Control c in this.Controls)
{
if(c is Label)
c as Label.Text = "";
}
All the best,
Martin
|
|
|
|
|
Using 'is' followed by 'as' causes two runtime type lookups to occur, one to do the boolean test, the other to actually perform the cast. Using 'as' alone followed by a test for null performs better.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Martin# wrote: c as Label.Text = "";
Apart from being a mess because it requires two lookups ( as someone else said ), I don't think this will work as you've typed it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Sure,
foreach(Control c in this.Controls)
{
if(c is System.Windows.Forms.Label)
{
System.Windows.Forms.Label l = c as System.Windows.Forms.Label;
l.Text ="";
}
}
-- modified at 7:15 Thursday 20th July, 2006
|
|
|
|
|
|
Of course,
I really understud what everybody else explaint me before.
but thanks for youre interest,
All the best,
Martin
|
|
|
|
|
Thanks for your statements,
All the best,
Martin
|
|
|
|
|
Is there no way, that
c as Label
causes an exception?
Thanks for youre time.
Martin
-- modified at 7:42 Thursday 20th July, 2006
|
|
|
|
|
No, c as Label will return null if c is not a Label.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Thank you,
I will go threw my code for cleaning up a little, I think.
All the best,
Martin
|
|
|
|
|
hello !
how to know that
what application/program is consuming what/how much resources of the system.
if some source code is there, plz send it
|
|
|
|
|
Please check this in MSDN System.Diagnostics.Process!
Process class in System.Diadnostics namespace includes all the things related to the work you are going to do. I hope you'll find your solution yourself.
Best Regards,
Rizwan Ahmed
|
|
|
|
|
G'day guys,
Today I have been playing with the option of having to insert additional user interface dialogs in the setup msi project in visual studio. One my goals in this setup msi project is to allow the user to select the option of whether they want to read the user guide or install the software. I have implemented this option as a two radiobutton form under the User Interface Option.
The problem I am experiencing is that, when the user selects the option of simply viewing the user guide, the setup msi starts to install the software once the software is half through the installation it then fires up the user guide then continues to complete the installation.
What do I need to do in order to prevent the setup msi from installing the software when the user selects the option of viewing the user guide document.
I have used the following article as a reference to get me started in customizing the user interface dialog:
http://www.codeproject.com/dotnet/Easy_Custom_Setup.asp
Any pointers will be most appreciated.
thanks
|
|
|
|
|
hi ,
I used a listbox for going to the next or previous record .For the savebutton event , I wrote this :
private void btnSave_Click(object sender, EventArgs e)<br />
{<br />
...<br />
PopulateListBox1();<br />
}
and For the PopulateListBox1() Function :
private void PopulateListBox1()<br />
{<br />
...<br />
if (ListBox1.Items.Count > 0)<br />
{<br />
ListBox1.SetSelected(ListBox1.Items.Count - 1, true);<br />
}<br />
...<br />
}<br />
thus , the last record is selected .If I want to select the current record when I press the savebutton , How can I do it ?
thanx
s_mostafa_h
-- modified at 2:17 Thursday 20th July, 2006
|
|
|
|
|
You can find the value or text in the list first and then made that selected.
Best Regards,
Apurva Kaushal
|
|
|
|
|
can u more explain ?
thanx a lot ,
s_mostafa_h
|
|
|
|
|
Sorry for the confusion, actually i got confused with dropdwon list control.
Cant you do something like this.
string str = "sometext";<br />
for(int i=0;i<=listBox1.Items.Count; i++)<br />
{<br />
if(listBox1.Items[i].Equals(str))<br />
{<br />
listBox1.SetSelected(i,true);<br />
}<br />
<br />
}
Best Regards,
Apurva Kaushal
|
|
|
|
|
apurva kaushal wrote: Cant you do something like this.
string str = "sometext";
"sometext" must be "ListBox1.Value" , but i recieve a "assigned local variable " Error .
REGARDS ,
s_mostafa_h
|
|
|
|
|
No sometext is the text what you need to be set as selected in the listbox.
Best Regards,
Apurva Kaushal
|
|
|
|
|
the Items'ListBox1 (e.g. field [name of company])are the same that with the selection of them , I can go to any record of the Table(next or before record ).
apurva kaushal wrote: sometext is the text what you need to be set as selected in the listbox.
Which Text ?
Regards ,
s_mostafa_h
|
|
|
|
|
Hi,
What i am trying to say is suppose you are having 3 items in your listbox i.e "abc", "mno" and "xyz". And you want to make "mno" as your selected item then what you need to do is put "mno" in place of "sometext". And you are done.
Best Regards,
Apurva Kaushal
|
|
|
|
|
thanks !
regards ,
s_mostafa_h
|
|
|
|
|
always welcome
Best Regards,
Apurva Kaushal
|
|
|
|
|
Hello,
in a program i'm writing I need to get a list with the accounts on my computer. (This must be shown in a combobox, but that's a detail). If I select an account I should need to convert them into a WindowsIdentity object. With that object, I then check file access rights...
Kind regards,
Frederik
|
|
|
|