Syntax error I believe: Invert in Set
cboLista
and value
and run the tests!
public ComboBox Combo
{
get
{
return cboLista;
}
set
{
cboLista = value;
}
}
Well a tip when doing this should be concerned with methods and actions and why your usercontrol
should have these features programmed. When I used this in Web I would program some actions that I would use by activating usercontrol
.
The event Resize
, we can set the size of the combo according to the size of the UserControl
dynamically in this way:
private void UCCombo_Resize(object sender, EventArgs e)
{
Combo.Width = this.Size.Width - 11;
}
When placing the object (UserControl) it will automatically leave the size of the combo as follows:
So,justconcluding,ithastobedynamic,butprogrammingshouldbedoneintheparentobject
Anotherexample:
CreateinyourUserControl
acodelikethis:
publicComboBoxStyleComboSytle{get{returncomboBox1.DropDownStyle;}set{comboBox1.DropDownStyle=value;}}
ByputtingUserControl
intoyourForm
itwillenablethissettingasbelow:
And by changing the style
the control will change this new setting as well.