Reputation: 5781
I'm using Yet Another TabControl in my project - it's custom, open sourced TabControl with support for designer. After solving some of its problems, I've stumbled upon a problem I have no clue how to solve.
When I run my application, YATabControl would select the same tab I selected in designer - which is not exactly what I want (I'd rather start with first tab) and I can't move through the tabs while application is running, because it tries to save property "SelectedIndex" on every change of tab.
It is set on designers ~onclick using:
RaiseComponentChanging( TypeDescriptor.GetProperties( Control )[ "SelectedIndex" ] );
RaiseComponentChanged( TypeDescriptor.GetProperties( Control )[ "SelectedIndex" ], oi, i );(old index, index).
I'm thinking - is there a way to disable designer from setting runtime value of property?
Upvotes: 3
Views: 3965
Reputation: 109
You need both attributes, so like this:
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool MyExtraProperty { get; set; }
Upvotes: 0
Reputation: 81675
I looked at the source code (didn't download it), but it looks like you have to tell the SelectedIndex
property to not serialize itself:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual int SelectedIndex {
get {
return yaSelectedIndex;
}
set {...}
}
Upvotes: 5