Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
680
How do I sort groups at runtime that have containers ?
posted

The below code (an example app) sorts groups that have been loaded dynamically BUT, I lose the user controls loaded into the group containers.

Can anyone tell me what I need to do to get this to work:

public Form1()

{

InitializeComponent();

ultraExplorerBar1.ViewStyle =
UltraExplorerBarViewStyle.Office2003;
ultraExplorerBar1.Style = UltraExplorerBarStyle.OutlookNavigationPane;

}

private void btnLoad_Click(object sender, EventArgs e)

{

ultraExplorerBar1.BeginUpdate();

ultraExplorerBar1.Groups.Clear();

AddControl(
new UserControl1("User Control 1"), "My User Control 1");AddControl(new UserControl1("User Control 2"), "My User Control 2");

ultraExplorerBar1.EndUpdate();

}

private void AddControl(Control c, string text)

{

UltraExplorerBarGroup newGroup = ultraExplorerBar1.Groups.Add(text);

newGroup.Text = text;

newGroup.Settings.Style =
GroupStyle.ControlContainer;c.Dock = DockStyle.Fill;

c.Parent = newGroup.Container;

}

private void btnReorder_Click(object sender, EventArgs e)

{

ultraExplorerBar1.BeginUpdate();

UltraExplorerBarGroup[ temp = new UltraExplorerBarGroup[ultraExplorerBar1.Groups.Count];

// copy groups into array and remove from explorer bar

for (int x = temp.Length - 1; x >= 0; x--)

{

temp[x] = ultraExplorerBar1.Groups[x];

ultraExplorerBar1.Groups.RemoveAt(x);

}

// reverse array

Array.Reverse(temp);

// add groups back

for (int x = 0; x < temp.Length; x++)

{

ultraExplorerBar1.Groups.Add(temp[x]);

}

ultraExplorerBar1.EndUpdate();

}