This quick start guides you through the steps of creating a simple form to display the car details using the InputPanel control.
Follow the steps below to get started:
C# |
Copy Code
|
---|---|
// TODO: This line of code loads data into the c1NWindDataSet1.Cars table. You can move, or remove it, as needed. this.carsTableAdapter.Fill(this.c1NWindDataSet1.Cars); |
VB |
Copy Code
|
---|---|
' TODO: This line of code loads data into the c1NWindDataSet1.Cars table. You can move, or remove it, as needed.
Me.carsTableAdapter.Fill(Me.c1NWindDataSet1.Cars)
|
Once the control is bound to a data source, you can also add your own components either to add more fields or to change the layout of the form. For instance, here, we are changing the layout to categorize the data by adding and moving input components.
To create a simple WinForms application in .NET using the InputPanel control, complete the following steps:
C# |
Copy Code
|
---|---|
// Create an instance of InputPanel control c1InputPanel1 = new C1.Win.InputPanel.C1InputPanel(); // Create an instance of Binding Source carsBindingSource = new System.Windows.Forms.BindingSource(this.components); // Create instances of each component to be placed on InputPanel hdrCars = new C1.Win.InputPanel.InputGroupHeader(); hdrDetails = new C1.Win.InputPanel.InputGroupHeader(); navCars = new C1.Win.InputPanel.InputDataNavigator(); lblBrand = new C1.Win.InputPanel.InputLabel(); txtBrand = new C1.Win.InputPanel.InputTextBox(); lblModel = new C1.Win.InputPanel.InputLabel(); txtModel = new C1.Win.InputPanel.InputTextBox(); lblCategory = new C1.Win.InputPanel.InputLabel(); txtCategory = new C1.Win.InputPanel.InputTextBox(); imgPicture = new C1.Win.InputPanel.InputImage(); lblPrice = new C1.Win.InputPanel.InputLabel(); numPrice = new C1.Win.InputPanel.InputTextBox(); |
C# |
Copy Code
|
---|---|
// Add InputPanel control to the form. Controls.Add(c1InputPanel1); // Add components to the InputPanel control c1InputPanel1.Items.Add(hdrCars); c1InputPanel1.Items.Add(navCars); c1InputPanel1.Items.Add(hdrDetails); c1InputPanel1.Items.Add(lblCategory); c1InputPanel1.Items.Add(txtCategory); c1InputPanel1.Items.Add(lblModel); c1InputPanel1.Items.Add(txtModel); c1InputPanel1.Items.Add(lblPrice); c1InputPanel1.Items.Add(numPrice); c1InputPanel1.Items.Add(imgPicture); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); |
C# |
Copy Code
|
---|---|
private void InitData() { dataSet = new DataSet(); string conn = "Select * from Cars"; OleDbDataAdapter da = new OleDbDataAdapter(conn, GetConnectionString()); da.Fill(dataSet, "Cars"); carsBindingSource.DataMember = "Cars"; carsBindingSource.DataSource = dataSet; } private string GetConnectionString() { string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\ComponentOne Samples\Common"; string conn = "provider = microsoft.jet.oledb.4.0; data source = " + path + @"\C1Nwind.mdb"; return conn; } |
C# |
Copy Code
|
---|---|
// Bind the InputPanel control to the data source c1InputPanel1.DataSource = carsBindingSource; // Bind the InputNavigator component to the data source navCars.DataSource = carsBindingSource; // Bind components of InputPanel to fields in the data source txtBrand.DataBindings.Add(new System.Windows.Forms.Binding("BoundValue", carsBindingSource, "Brand", true)); txtModel.DataBindings.Add(new System.Windows.Forms.Binding("BoundValue", carsBindingSource, "Model", true)); txtCategory.DataBindings.Add(new System.Windows.Forms.Binding("BoundValue", carsBindingSource, "Category", true)); numPrice.DataBindings.Add(new System.Windows.Forms.Binding("BoundValue", carsBindingSource, "Price", true)); imgPicture.DataBindings.Add(new System.Windows.Forms.Binding("BoundValue", carsBindingSource, "Picture", true)); InitData(); |
C# |
Copy Code
|
---|---|
// Configure the InputPanel control
c1InputPanel1.DesignScaleFactor = 1.282051F;
c1InputPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
C# |
Copy Code
|
---|---|
// Configure the InputNavigator component navCars.MoveFirstImage = ((System.Drawing.Image)(resources.GetObject("navCars.MoveFirstImage"))); navCars.MoveFirstToolTip = "Move First"; navCars.MoveLastImage = ((System.Drawing.Image)(resources.GetObject("navCars.MoveLastImage"))); navCars.MoveLastToolTip = "Move Last"; navCars.MoveNextImage = ((System.Drawing.Image)(resources.GetObject("navCars.MoveNextImage"))); navCars.MoveNextToolTip = "Move Next"; navCars.MovePreviousImage = ((System.Drawing.Image)(resources.GetObject("navCars.MovePreviousImage"))); navCars.MovePreviousToolTip = "Move Previous"; |
C# |
Copy Code
|
---|---|
// Configure other controls // Set the text to be displayed in components hdrCars.Text = "&Cars"; hdrDetails.Text = "Details"; lblBrand.Text = "&Brand:"; lblModel.Text = "&Model:"; lblCategory.Text = "Cat&egory:"; lblPrice.Text = "&Price:"; |
C# |
Copy Code
|
---|---|
// Set the dimensions of the components
lblBrand.Width = 95;
lblModel.Width = 95;
lblCategory.Width = 95;
txtCategory.Width = 95;
imgPicture.Height = 90;
imgPicture.Width = 150;
lblPrice.Width = 95;
|
C# |
Copy Code
|
---|---|
//Set the break type to shift the next component to a new column
numPrice.Break = C1.Win.InputPanel.BreakType.Column;
|