Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Duplicate Controls & Databinding
 

Duplicate Controls & Databinding

Hello,
I have a textbox that acts as a headerand a panel below it with multiple data binded controls. The header and panel act as a way to store diffrent people. Below that panel their is another textbox that when clicked should add a new panel with all the controls (data binded) & control events, along with adding another textbox below that panel to allow for a new person to be added. I have no clue how to "duplicate" controls with the events, not to mention still have them databinding. Any help would be great.

------------------------------------------------------------------------
Doe, John A. (Textbox with border)
------------------------------------------------------------------------
Controls
Controls
Controls
Controls< - Panel holding controls
Controls
Controls
Controls
------------------------------------------------------------------------
Add New Person (Textbox with border)
------------------------------------------------------------------------
Grant McElroy  Friday, July 28, 2006 12:58 AM

Create a class with these controls in it. Create them dynamically like this.

Public Class DataGridClass

ProtectedGroupbox as new groupbox
Protected Friend withevents Datagrid as New Datagrid

Etc Next control... etc

'.....Declare the event handlers by Hand with appropriate signatures

Then

Datagrid.name = "DataGrid"

Datagrid.size = new size (100,100)
Datagrid.location = new point (10,10)

Groupbox1.controls.add(Datagrid)

'Your are going to have to reference the controls through Properties and methods.
'If this is going to be on form1, for example, event handlers can call public methods on form1.

End Class

Finally to add this to form1

Dim DGClass as New DataGridClass

Me.controls.add(DGClass)

Talk to the class via the properties you write for it. The IDE snippet edit has property snippetsin it under Common Code Patterns.

ReneeC  Friday, July 28, 2006 2:52 AM

You can use google to search for other answers

Custom Search

More Threads

• Datagridview Updating problems
• Adding a property to underlying bound object does not add corresponding column to bound datagridview
• How do you load information from a bindingsource into a DataGridView?
• DataGridView Autoscrolling problem
• DataGridView Default Date Format
• Binding data source to Checkedlistbox in C#.NET
• Combobox initially loads with the id not the name
• Winforms Datagrid Vs DataRow BeginEdit
• Is it possible for two forms to reference the same instance of a dataset?
• firing gridview after getting data from four fields (including 2 dropdowns and 2 text fields)