Description
The UpdateSplitFraction
method is a virtual method of the SplitContainer
class in the Sandbox.UI
namespace. This method is responsible for updating the fraction of the split between the two panels in the SplitContainer
. The fraction determines the relative size of the left (or top) and right (or bottom) panels.
Usage
To use the UpdateSplitFraction
method, you need to call it on an instance of the SplitContainer
class. Pass a float
value as the parameter, which represents the new fraction of the split. The value should be between 0 and 1, where 0 means the left panel is minimized, and 1 means the right panel is minimized.
Ensure that the fraction value respects the MinimumFractionLeft
and MinimumFractionRight
fields, which define the minimum size constraints for the panels.
Example
// Create a new SplitContainer instance
SplitContainer splitContainer = new SplitContainer();
// Update the split fraction to 0.3
// This means the left panel will take 30% of the space
splitContainer.UpdateSplitFraction(0.3f);
// Ensure the fraction respects the minimum constraints
float minLeft = splitContainer.MinimumFractionLeft;
float minRight = splitContainer.MinimumFractionRight;
if (0.3f < minLeft || 0.3f > (1 - minRight))
{
// Handle the case where the fraction is out of bounds
// For example, set to a default value or log a warning
}