hi, the situation is: i made a UserControl and the UserControl is listed in the toolbox,
Code Snippet
public partial class MyControl : UserControl
{
public MyControl()
{ InitializeComponent(); }
public MyControl(Boolean x)
{ InitializeComponent(); }
}
now i want is, if i drag in the designer from the toolbox MyControl on a Form, that the second constructor should be called with pre defined parameter. For example that i can define some where how to retrive the value to pass and the design generator create the right code. | | Coke-22 Friday, August 24, 2007 3:40 PM | Hi, Coke-22,
Based on my understanding, you want to call the second constructor while dragging the user control to designer, don't you?
However, I think it is not possible to choose that constructor while dragging from toolbox to designer, because it is not possible to build and pass the parameters at that time.
But if you want to change some properties during design time, you can try to use property window(F4), or use the smart tag technology.
Here is a good sample for how to make a Smart Tag http://msdn.microsoft.com/msdnmag/issues/05/07/DesignerActions/
Hope this helps,
Regards
| | Yu Guo �MSFT Wednesday, August 29, 2007 3:18 AM | No, but found a work arround. You can define a property that takes a boolen for example and in the set (setter) part u can check if value is true then make all those things u want to make in the contructor with additional paramters. and if this should have behavour like an constructor make sure to run code only once.
smart tags was to complicated :-).
| | Coke-22 Thursday, September 06, 2007 1:44 PM | Hi, Coke-22,
Based on my understanding, you want to call the second constructor while dragging the user control to designer, don't you?
However, I think it is not possible to choose that constructor while dragging from toolbox to designer, because it is not possible to build and pass the parameters at that time.
But if you want to change some properties during design time, you can try to use property window(F4), or use the smart tag technology.
Here is a good sample for how to make a Smart Tag http://msdn.microsoft.com/msdnmag/issues/05/07/DesignerActions/
Hope this helps,
Regards
| | Yu Guo �MSFT Wednesday, August 29, 2007 3:18 AM | hi, i was looking for
call the second constructor while dragging the user control to designer
| | Coke-22 Friday, August 31, 2007 8:10 AM | Hi, Coke-22,
As I answered in my last post,
" I think it is not possible to choose that constructor while dragging from toolbox to designer"
Orcould youtell me how can you define the parameter while you are dragging?
Regards
| | Yu Guo �MSFT Friday, August 31, 2007 8:22 AM | No, but found a work arround. You can define a property that takes a boolen for example and in the set (setter) part u can check if value is true then make all those things u want to make in the contructor with additional paramters. and if this should have behavour like an constructor make sure to run code only once.
smart tags was to complicated :-).
| | Coke-22 Thursday, September 06, 2007 1:44 PM |
|