I am having trouble figuring out how to adjust the width of my tabs. I am showing a graphic on the left side and a Close button on the right. However, there seems to be a lot of wasted space between the end of the text and the Close button (see screen cap below). How can I reduce the amount of blank space?
Hi rehemann,
In this scenario, I believe that it should be possible to determine the length of the text used as the tab’s caption and then setting the width of the tab to this value, after compensating for the fixed width of the image and close-control button.
I will take a closer look into this issue and I will post my findings/developed approach on this thread; if you have any further questions in the meantime, please let me know.
Sincerely,Chris KDeveloper Support EngineerInfragistics, Inc.www.infragistics.com/support
Thanks for the reply, Chris. What would be the best event to use for this calculation? TabDisplayed maybe?
You are certainly welcome. I have investigated this issue further and I have found that the default behavior for the UltraTabControl is to automatically compensate for tab caption length by adjusting the width of the associated tab header. This behavior may be overridden, however, if the FixedWidth of the tab is being modified programmatically, which may be unintentional or intended.
In any case, it is certainly possible to adjust the tab width programmatically to compensate for varying lengths of tab caption text and appearances.
I have constructed and attached a sample which demonstrates one possible approach. In this implementation, each tab within the UltraTabControl’s tab collection is iterated thru, its caption length in pixels is determined and then this value is used to calculate the expected tab width; also compensating for conditions where the tab image may be null or where the close control button, (or both) are excluded from the tab.
As the UltraTabControl does not extend an event handler for when tabs are loaded or displayed, I have called the calculation method whenever the TabControl is invalidated as well as during the Form_Load event when the tabs are initialized; in the event tabs are closed and then reloaded, their appearance will remain consistent even if the text length is modified.
Please find the sample attached.
If you have any further questions regarding this solution, please let me know.
Chris:
I'm using the UltraTabbedMdi control, not the UltraTab control, so the events are different. I've played around with your code today, but I'm struggling with finding the proper event to put it into. I've tried the PropertyChanged event, but it does not seem to be picking up the text property of the form properly. Can you point me in the right direction as to what event I should us?
I apologize for the delay. This implementation may still remain relevant to the UltraTabbedMdiManager1. Although as in this case you would be using the contents of discrete forms for populating the tab pages; this being the case, I can imagine that you may be experiencing an issue if you are trying to obtain the text of the tab, (which may initially be null).
In this case, you could set the expected text of the tabs when the form is loaded to that of their associated forms.
For setting the actual tab widths, I would recommend setting them initially via a call to the calculate method adjusted for the UltraTabbedMDIManager when the tabs are initialized, (InitializeTab) as well as when they are displaying; in the event that tabs are closed and then re-created.
Please let me know if you require any further information.