Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Column Headers
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Divers
Thread ID:
01405535
Message ID:
01405705
Vues:
33
>>>I am creating a list control. I have created a separate column headers control called ColumnHeaders. I have also created a columns
>>>collection that is subclasses from the Collection class. The headers on this control should work just like the headers on a DataGridView or a ListView control.
>>>
>>>In a DataGridView there is a public Columns collection. Adding a column to the collection also adds the corresponding header, yet there
>>>is no public reference to the Headers themselves.
>>>
>>>So....
>>>
>>>The constructor of my Columns collection class receives a reference to the list into a private member called _Parent. This way in the
>>>Add method I can call back into the list.
>>>
>>>The problem is that if I make the ColumnHeaders control public, then it's exposed outside the list.
>>
>>> If I make it private, it's not available from the Columns collection via the reference I passed into the constructor.
>>
>>I'm not sure I understand. Can you show some basic code that illustrates the problem ?
>
>I'm not sure how to explain what I'm asking.
>
>There are 4 parts to my control:
>
>Part 1 - The list control I'm creating
>Part 2 - The column headers. This is a separate control which is already written and is added to the list in the constructor. The
> headers are similar to the those you see in Windows Explorer's Details view.
>Part 4 - The collection class. This is a collection of column objects.
>Part 3 - The column object. One column object exists in the collection for each column in the control.
>
>To set up the columns for the list you would do:
>
>
>Column colName = new Column();
>colName.Caption = "Employee";
>colName.ControlType = RowControls.Label;
>colName.Width = 100;
>colName.BoundColumnName = "empname";
>colName.Key = "name";
>
>Column colNotes = new Column();
>colNotes.Caption = "Notes...";
>colNotes.ControlType = RowControls.Button;
>colNotes.Width = 75;
>colNotes.BoundColumnName = "empnotes";
>colNotes.Key = "notes";
>
>Column colEmail = new Column();
>colEmail.Caption = "Email";
>colEmail.ControlType = RowControls.LinkLabel;
>colEmail.Width = 75;
>colEmail.BoundColumnName = "empemail";
>colEmail.Key = "weburl";
>
>List1.Columns.Add(colName);
>List1.Columns.Add(colNotes);
>List1.Columns.Add(colEmail );
>
>
>When a column object is added to the collection the Add method will need to call back into the list and then into the ColumnHeaders
>control to add the column's header, taking it's text and width from the Column object.
>
>The question is this... In a DataGridView or ListView or any other control with column headers, there is no Headers collection exposed. Yet the column headers appear on the list when you add them.

>
>So, how do I add column headers via my collection class while keeping the ColumnHeaders control from being exposed outside the
>list class?
>
>I think I'll try to get it a bit more functional, then zip it up & load it onto the UT so other's can see what I'm trying to do.

Don't know how it affects what you are doing but the architecture of the DataGridView is straightforward.
The DataGridView.Columns property is an instance of DataGridViewColumnCollection which (surprise :-}) contains a list of DataGridViewColumn objects. Each DataGridViewColumn has a HeaderCell property referencing a DataGridViewColumnHeaderCell object.
So the DGV doesn't hold a list of headers - each column holds it's own header object. You can access the header cell so:
dataGridView1.Columns[0].HeaderCell.ToolTipText = "Fred";
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform