-
Jun 17th, 2014, 12:39 PM
#1
Thread Starter
Lively Member
Custom DataGridView UserControl in DLL - get Columns collection to work?
I've been trying to get a custom control working, a DGV and some embellishments, in a DLL. In a test project the new control shows up OK once added to the toolbox, and I've managed to get it to show data with this :
Code:
<System.ComponentModel.ComplexBindingProperties("DataSource", "DataMember")>
Public Class MyDataGridView
Public Property DataSource() As Object
Get
Return dgvMain.DataSource
End Get
Set(ByVal value As Object)
dgvMain.DataSource = value
End Set
End Property
Public Property DataMember() As String
Get
Return dgvMain.DataMember
End Get
Set(ByVal value As String)
dgvMain.DataMember = value
End Set
End Property
However, I would like the Columns collection to act like it normally would in a standard DGV. The following code works to some degree, giving me a Columns collection property where the ... button brings up a Columns editor (one that is titled "DataGridViewColumn Collection Editor" rather than the usual "Edit Columns", and a column of numbered RowHeaders which isn't standard - but that's another question. Feel free to answer it though! Already tried decorating it with a <System.ComponentModel.Editor( attribute, but with no success - some pages online suggest that the standard DGV Columns editor is a private affair which we don't get to play with).
Code:
Public Overridable Property Columns As Windows.Forms.DataGridViewColumnCollection
Get
Return dgvMain.Columns
End Get
Set(ByVal value As Windows.Forms.DataGridViewColumnCollection)
' dgvMain.Columns = value ' error - it's readonly!
End Set
End Property
I can delete columns and make other changes that show up at design time, but when I run the project for real, it's back to the full results from the dataset, ignoring my changes to the columns. Is there any way to get around this? The columns collection seems to be readonly, and the Property Set code doesn't get called (a msgbox in there never appears).
Am I going about this the right or wrong way? Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|