I have my Color Picker Control which have ChildWinEditLayout Parent property. Now I want to use generics. I want to have my NewChildWinEditLayout Parent or OldChildWinEditLayout to be set as MyParent.
How can I make this code only have one constructor using generics ?
public partial class ColorPickerControl : UserControl { OldChildWinEditLayout myParent; NewChildWinEditLayout myParentControl; string tag; public ColorPickerControl(OldChildWinEditLayout myParent1, string tag1) { tag = tag1; myParent = myParent1; InitializeComponent(); } public ColorPickerControl(NewChildWinEditLayout myParent1, string tag1) { tag = tag1; myParentControl = myParent1; InitializeComponent(); }}
When I compile the code it show me an error in ColorPickerControl that says:
"Error 1 'object' does not contain a definition for 'SetForeColor' and no extension method 'SetForeColor' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)"
Object myParent; string tag; public ColorPickerControl(Object myParent1, string tag1) { tag = tag1; myParent = myParent1; InitializeComponent(); } if (tag == "b") { //myParent.SetBackColor(s); } else { myParent.SetForeColor(s); }
Open in new window
then
Open in new window
finally
Open in new window
When I compile the code it show me an error in ColorPickerControl that says:
"Error 1 'object' does not contain a definition for 'SetForeColor' and no extension method 'SetForeColor' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)"
Open in new window
How can I solve this issue?