Click here to Skip to main content
15,902,112 members
Home / Discussions / C#
   

C#

 
AnswerRe: How do I select the "Directory" Pin
Luc Pattyn1-Feb-07 6:31
sitebuilderLuc Pattyn1-Feb-07 6:31 
QuestionC# equilavent functionality to a C++ Vector Pin
rishid71-Feb-07 5:15
rishid71-Feb-07 5:15 
AnswerRe: C# equilavent functionality to a C++ Vector Pin
Mircea Puiu1-Feb-07 5:30
Mircea Puiu1-Feb-07 5:30 
AnswerRe: C# equilavent functionality to a C++ Vector Pin
Luc Pattyn1-Feb-07 6:37
sitebuilderLuc Pattyn1-Feb-07 6:37 
AnswerRe: C# equilavent functionality to a C++ Vector Pin
Marc Clifton1-Feb-07 7:13
mvaMarc Clifton1-Feb-07 7:13 
Questionhow to put the gradient effect on the BindingNavigator object's bacground in Windows Forms Pin
Rocky#1-Feb-07 5:11
Rocky#1-Feb-07 5:11 
QuestionControls on programmatically added TabPages Pin
jimkeating1-Feb-07 5:09
jimkeating1-Feb-07 5:09 
AnswerRe: Controls on programmatically added TabPages Pin
Luc Pattyn1-Feb-07 6:47
sitebuilderLuc Pattyn1-Feb-07 6:47 
Hi,

first and for all there is no fundamental difference between Controls added by using the
Visual Studio Designer, and Controls added programmatically; after all the only thing
Designer does is adding code to yours, so you may want to have a look at how it translater
your interactions into real code.

Second, the trick is in keeping a reference to the Controls you create:
class XXX {
    void addALabel() {
        Label label1=new Label();
        label1.Text="unaccessible";
        this.Controls.Add(label1);
    }
    private Label label2;

    void addAnotherLabel() {
       label2=new Label();
       label2.Text="good";
       this.Controls.Add(label2);
    }

    void changeALabel() {
        label2.Text="new text";
    }
}

In the above example, label1 is created, added to the form, it will be visible, but
you can not (at least not easoly) change it anymore, since the variable "label1" indeed
is "out of scope" as soon as the {} brackets around it get closed.

On the other hand, label2 is available (as long as its surrounding brackets dont close).
So the changeALabel() method can change its text.

The same applies to all kinds of Controls, in no matter how complex your form gets.

Hope this helps.

Smile | :)



Luc Pattyn

GeneralRe: Controls on programmatically added TabPages Pin
jimkeating1-Feb-07 7:15
jimkeating1-Feb-07 7:15 
QuestionDependency issue Pin
Dan Neely1-Feb-07 5:04
Dan Neely1-Feb-07 5:04 
AnswerRe: Dependency issue Pin
Luc Pattyn1-Feb-07 6:59
sitebuilderLuc Pattyn1-Feb-07 6:59 
GeneralRe: Dependency issue Pin
Dan Neely1-Feb-07 7:33
Dan Neely1-Feb-07 7:33 
GeneralRe: Dependency issue Pin
Luc Pattyn1-Feb-07 7:48
sitebuilderLuc Pattyn1-Feb-07 7:48 
QuestionCalling SP from .net Pin
Astricks1-Feb-07 3:43
Astricks1-Feb-07 3:43 
AnswerRe: Calling SP from .net Pin
Michael P Butler1-Feb-07 3:51
Michael P Butler1-Feb-07 3:51 
GeneralRe: Calling SP from .net Pin
Astricks1-Feb-07 3:58
Astricks1-Feb-07 3:58 
GeneralRe: Calling SP from .net Pin
Russell Jones1-Feb-07 22:02
Russell Jones1-Feb-07 22:02 
GeneralRe: Calling SP from .net Pin
Michael P Butler1-Feb-07 23:10
Michael P Butler1-Feb-07 23:10 
AnswerRe: Calling SP from .net Pin
Pete O'Hanlon1-Feb-07 4:38
mvePete O'Hanlon1-Feb-07 4:38 
QuestionResponse.Redirect Pin
acodman1-Feb-07 3:33
acodman1-Feb-07 3:33 
AnswerRe: Response.Redirect Pin
ednrgc1-Feb-07 3:35
ednrgc1-Feb-07 3:35 
AnswerRe: Response.Redirect Pin
Luc Pattyn1-Feb-07 3:37
sitebuilderLuc Pattyn1-Feb-07 3:37 
AnswerRe: Response.Redirect Pin
Michael P Butler1-Feb-07 3:45
Michael P Butler1-Feb-07 3:45 
QuestionXML Pin
snouto1-Feb-07 3:30
snouto1-Feb-07 3:30 
AnswerRe: XML Pin
Dustin Metzgar1-Feb-07 3:48
Dustin Metzgar1-Feb-07 3:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.