Dynamically create dock panel using devexpress tool in C#

first install the DXperience from this link

http://www.filecrop.com/Dxperience-.net.html

then u have to add three refernces in refernces box.

devexpress.jpg

devexpress2.jpg

devexpess3.jpg

And after this u have to import this from library

using DevExpress.XtraBars.Docking;
 
Then write the code below:

ListBox lBox;

      private void Form1_Load(object sender, EventArgs e)
{
   DockManager dockManager1 = new DockManager(this);
   DockPanel panel1 = dockManager1.AddPanel(DockingStyle.Right);
   panel1.Text = "Properties";
   DockPanel panel2 = panel1.AddPanel();
   panel2.Text = "Seetings";
   

   // Transform the split container into a tab container.

   DockPanel container = panel1.ParentPanel;
   container.Tabbed = true;
   lBox = new ListBox();
   lBox.Items.AddRange(new string[] { "Item 1", "Item 2", "Item 3" });
   lBox.Dock = DockStyle.Fill;
   listBox2.Dock = DockStyle.Fill;
   panel1.ControlContainer.Controls.Add(lBox);
   panel2.ControlContainer.Controls.Add(listBox2);

   lBox.MouseClick+=new MouseEventHandler(lBox_MouseClick);
}

public void lBox_MouseClick(object sender, EventArgs e)
{
     if (lBox.SelectedIndex == 0)
     {
          MessageBox.Show("item1");
     }
     else if (lBox.SelectedIndex == 1)
     {
          MessageBox.Show("item2");
     }
     else if (lBox.SelectedIndex == 2)
     {
           MessageBox.Show("item3");
     }
}

Ebook Download
View all
Learn
View all