Click here to Skip to main content
15,885,622 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to Convert Amibroker AFL to Dll setup file with License Manager Pin
Member 125746279-Jun-16 2:17
Member 125746279-Jun-16 2:17 
GeneralRe: How to Convert Amibroker AFL to Dll setup file with License Manager Pin
Pete O'Hanlon9-Jun-16 2:33
mvePete O'Hanlon9-Jun-16 2:33 
GeneralRe: How to Convert Amibroker AFL to Dll setup file with License Manager Pin
Eddy Vluggen10-Jun-16 11:55
professionalEddy Vluggen10-Jun-16 11:55 
QuestionItem deleted in control even already assign to another variable. Pin
Le@rner8-Jun-16 21:11
Le@rner8-Jun-16 21:11 
AnswerRe: Item deleted in control even already assign to another variable. Pin
Pete O'Hanlon8-Jun-16 22:27
mvePete O'Hanlon8-Jun-16 22:27 
AnswerRe: Item deleted in control even already assign to another variable. Pin
Richard MacCutchan8-Jun-16 22:43
mveRichard MacCutchan8-Jun-16 22:43 
AnswerRe: Item deleted in control even already assign to another variable. Pin
OriginalGriff8-Jun-16 22:47
mveOriginalGriff8-Jun-16 22:47 
AnswerRe: Item deleted in control even already assign to another variable. Pin
BillWoodruff8-Jun-16 23:05
professionalBillWoodruff8-Jun-16 23:05 
You won't "stop this:" what you observe is the way that object references are supposed to work;
multiple variables can hold copies of the pointer to the instance of a Class or Struct.

To create another instance of 'MyPanel which is "independent" of the first instance you have to ... well ... create another instance or "clone" the first instance; by clone, I mean create a new instance and copy the values of all Fields, Controls, Properties, etc. No, there's no built-in operator to do this.

What you probably want to do is to create a UserControl (they are about as light-weight as a Panel); first create a UserControl with the minimum number of Controls ... the "simplest" version ... then create another UserControl and modify it's Class definition so it inherits from your first UserControl:

1. the first Usercontrol's constructor:
C#
public partial class MyCustomPanel : UserControl
{
    public MyCustomPanelSimple()
    {
        InitializeComponent();
    }
}
2. the second UserControl's modified constructor:
C#
public partial class MyCustomPanel2 : MyCustomPanel
{
    public MyCustomPanel2()
    {
        InitializeComponent();
    }
}
Assuming you've put one Button on the first (simpler) UserControl, you'll find that when you open the design-view for the second UserControl that Button appears, and is 'locked; you can't assign EventHandlers to its Events. But, the Button is ... there. You just have to do this to get access to it:
C#
public MyCustomPanel2()
{
   InitializeComponent();

   TheButton = Controls["customPanelButton1"] as Button;
}

private Button TheButton;
Or, you can do an evil thing, and go make the access modifier for the Button in the first Panel (simpler) 'public: to do that you have to modify the declaration of that Button in the designer.cs file which is a very wicked thing to do ... better you should get a reference in the (lame) way shown here. In case you wonder why Microsoft made creating Form/Control inheritance so painfully awkward to implement, be assured you are not alone.

One way to avoid this awkwardness is to make your custom Controls "composite:" make the simplest one, then make another one where you drag-drop an instance of the first one onto the design surface of the second one where you add additional Controls ... and, so on. And, then you can have fun getting references to the interior Controls of your UserControls-in-UserControls.
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008

GeneralRe: Item deleted in control even already assign to another variable. Pin
Le@rner9-Jun-16 2:40
Le@rner9-Jun-16 2:40 
QuestionIgnore Error Pin
sunsher8-Jun-16 20:05
sunsher8-Jun-16 20:05 
AnswerRe: Ignore Error Pin
OriginalGriff8-Jun-16 20:30
mveOriginalGriff8-Jun-16 20:30 
GeneralRe: Ignore Error Pin
sunsher12-Jun-16 12:42
sunsher12-Jun-16 12:42 
GeneralRe: Ignore Error Pin
OriginalGriff12-Jun-16 21:05
mveOriginalGriff12-Jun-16 21:05 
QuestionSystem.NullReferenceException Pin
sunsher8-Jun-16 12:48
sunsher8-Jun-16 12:48 
AnswerRe: System.NullReferenceException Pin
Matt T Heffron8-Jun-16 13:56
professionalMatt T Heffron8-Jun-16 13:56 
AnswerRe: System.NullReferenceException Pin
BillWoodruff8-Jun-16 13:58
professionalBillWoodruff8-Jun-16 13:58 
GeneralRe: System.NullReferenceException Pin
sunsher8-Jun-16 18:57
sunsher8-Jun-16 18:57 
GeneralRe: System.NullReferenceException Pin
sunsher8-Jun-16 19:10
sunsher8-Jun-16 19:10 
GeneralRe: System.NullReferenceException Pin
Pete O'Hanlon8-Jun-16 21:15
mvePete O'Hanlon8-Jun-16 21:15 
GeneralRe: System.NullReferenceException Pin
BillWoodruff8-Jun-16 21:54
professionalBillWoodruff8-Jun-16 21:54 
Questionpassword policy using c# Pin
forest4ever7-Jun-16 20:33
forest4ever7-Jun-16 20:33 
AnswerRe: password policy using c# Pin
Garth J Lancaster7-Jun-16 20:44
professionalGarth J Lancaster7-Jun-16 20:44 
AnswerRe: password policy using c# Pin
Mycroft Holmes7-Jun-16 22:19
professionalMycroft Holmes7-Jun-16 22:19 
AnswerRe: password policy using c# Pin
OriginalGriff7-Jun-16 22:28
mveOriginalGriff7-Jun-16 22:28 
QuestionSet window on top from ShellExecute? Pin
kenw2327-Jun-16 11:25
kenw2327-Jun-16 11:25 

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.