Syntax error I believe: Inverts the Set
cboLista
and value
and take the tests!
public ComboBox Combo
{
get
{
return cboLista;
}
set
{
cboLista = value;
}
}
Good a hint when doing this should concern you with methods and actions and so your usercontrol
should have these features programmed. When I used this in Web I programmed some actions that I was going to use usercontrol
.
Reinforcing what I said the programming should go to the object and then you should use Usercontrol as reference for some settings, I’ll leave an example:
The event Resize
, we can configure the size of the combo according to the size of the UserControl
dynamically in that 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 combo size this way:
So, just to conclude, it can be dynamic, but the programming must be done on the Father object
Another example:
Create in your UserControl
a code like that:
public ComboBoxStyle ComboSytle
{
get
{
return comboBox1.DropDownStyle;
}
set
{
comboBox1.DropDownStyle = value;
}
}
By placing the UserControl
in his Form
it will enable this image equal configuration below:
And changing the style
control will change this new configuration as well.
I realized the mistake, but it still didn’t work out the way I wanted it to. I can only change the properties of the combobox through the code, for example:
cboTeste.Combo.DropDownStyle = ComboBoxStyle.DropDownList;
In visual mode the property Combo appears in the properties tab, I make the property change Dropdownstyle I see on the screen the modification (still in visual mode), but when executing these modifications do not appear. But we can already continue the work using code, so identify what the problem for visual mode I put here.– user2506112
"
mas ao executar aplicação estas modificações não aparecem
" This looks like property being set at some point in the code. The debugger is your friend.– Oralista de Sistemas