Hi,
I have a tab control that has 4 tabs. There is a save button that only shows on the last tab. Sometimes the user doesn't have permissions to save the record so we make the save button visible = false in some cases.
In the form closing event we inspect the value of the save buttons visible property to know if we even have to check for dirty since they can't save if the visible property is set to false.
The problem is that if you are on any other tab than the 4th tab the save button's visible property will always be false.
Is there a way around this issue?
Thanks
Randy
This is expected behavior. We set the controls' visibility to false to ensure that they're not displayed on the screen, when they're on tabs other than the active tab.
I suggest you use a different value besides the save button's visibility to control this functionality. My advice would be to use a form-level property for this, which you can set to true or false in the same way you set the save button's visibility.
Hi Vince,
Thanks for the reply. This is very undesireable. Checking the visible property for the save button is only one problem this causes for us. We also do validation of the values in controls and we don't validate controls that are not visible. As you can imagine in a complicated application like ours that has hundreds of controls on the form and lots of controls change from visible to not visible all the time based on user input this is a big deal.
This seems like it would have other undesireable side effects too like causing the visibleChanged event to fire. We don't use this, but it seems like it could cause problems.
There must be some other work around. For example, internally Infragistics must be keeping track of what the original visible property value was so that it can be set back to the correct value when the tab is displayed. Can we have access to this property?
This is old, but it would be more advantageous to bind the controls to a controller that allows access to a Domain Model.
This way any of the logic necessary to discern between various states is handled, be a Controller that manages the pages state( as far as data is concerned) and the actual state of the control isn't being depended on. Since obviously you are triggering these and that would make it's state volatile.
Nick
Randy,
I do not believe that that UltraTabControl maintains the original state of the Visible property of every control since this would be extremely inefficient. What is likely happening here is that the UltraTabControl is setting the TabPageControl's Visible property to false (since you don't want to show the TabPageControl for a non-selected tab). The Visible property takes into account the visibility of any parents as well; if you have a button in a panel and set the panel's Visible property to false, the button's Visible property will also return false, even though it was never explicitly set as such.
Vince is correct in that there will have to be some other means of determining what is valid or not; you should still be able to access the values of all controls, but the Visible property will not be a reliable means.
-Matt