[]
The following quick start guides the user how to create a simple application using Accordion. In this quick start, you'll create a new project in Visual Studio, add the Accordion control to your application, add pages to it and then add content to content area of the pages.
Switch to the code view and create controls to be shown in the pages. In this example, we created two ListViews and added items in them using the following code.
private void InitTasksList()
{
//create ListView
tasksListView = new ListView();
//dock to fill
tasksListView.Dock = DockStyle.Fill;
//set the View to List since we want the items to be shown as list
tasksListView.View = View.List;
//assign ImageList, will be used to show images for the items
tasksListView.SmallImageList = imgList;
//add items to the listview
tasksListView.Items.Add("All tasks", "task");
tasksListView.Items.Add("Completed", "task");
tasksListView.Items.Add("Active", "task");
tasksListView.Items.Add("Pending", "task");
}
private void InitMaiList()
{
//create ListView
mailListView = new ListView();
//dock to fill
mailListView.Dock = DockStyle.Fill;
//set the View to List since we want the items to be shown as list
mailListView.View = View.List;
//assign ImageList, will be used to show images for the items
mailListView.SmallImageList = imgList;
//add items to the listview
mailListView.Items.Add("AllItems", "folder");
mailListView.Items.Add("Inbox", "folder");
mailListView.Items.Add("Sent", "folder");
mailListView.Items.Add("Drafts", "folder");
}
Add the controls to the content panel of the AccordionPage. Here, we are adding the two ListViews in the two pages to display different options along with images. These images are accessible from the Images folder in the application.
ListView mailListView;
ListView tasksListView;
ImageList imgList;
public Form1()
{
InitializeComponent();
//create an ImageList
imgList = new ImageList();
//add images with custom keys
imgList.Images.Add("folder", Resources.Folder);
imgList.Images.Add("task", Resources.Journal_48);
//initialize the ListView control for mails page
InitMaiList();
//initialize the ListView control for tasks page
InitTasksList();
var mailPage = c1Accordion1.Pages[0];
var taskPage = c1Accordion1.Pages[1];
mailPage.ContentHeight = taskPage.ContentHeight = 200;
//Add controls in content area of AccordionPage
mailPage.Controls.Add(mailListView);
taskPage.Controls.Add(tasksListView);
}