Proper way to handle ColumnStyle for Custom DataGrid?

V

Vagabond Software

I am creating a custom datagrid based, in part, from someone else's code. The author declared a derived datagrid class in a windows form, then declared a derived ColumnStyle class, in the same form, that accepted his custom grid type as an argument. For example:

public class HisCustomGrid : DataGrid {
public HisCustomGrid() { } }

public class HisColumnStyle : DataGridTextBox {
public HisColumnStyle(int anyint, HisCustomGrid grid) { } }

I now have a Windows Control Library with all the features I need, but I still need to include the column styles. I'm not sure how to go about doing this.

1. I think the 'right' way to go would be the columnstyles as a nested class within my custom datagrid class, but I'm not sure how to direct the columnstyle to my grid. For example:

public class MyCustomGrid : DataGrid {
public MyCustomGrid() { }
public class MyColumnStyle(int colIndex, ???what here???) { } }

2. I assume the other option is to add it as a separate class within my Windows Control Library namespace, but I still don't know how to make it act upon my custom grid. For Example:

namespace MyCustomGrid {
public class MyCustomGrid : DataGrid {
public MyCustomGrid() { } }

public class MyColumnStyle : DataGridTextBoxColumn {
public MyColumnStyle(int colIndex, ???what here???) { } } }

Any help would be greatly appreciated.

- carl
 
D

Dave

It seems obvious to me so please tell me if I'm missing something:

public class MyCustomGrid : DataGrid {
public MyCustomGrid() { }
public class MyColumnStyle(int colIndex, ???what here???) { } }

???what here??? = MyCustomGrid grid

So, this becomes:

public class MyCustomGrid : DataGrid {
public MyCustomGrid() { }
public class MyColumnStyle(int colIndex, MyCustomGrid grid) { } }

If you are asking about best coding practices I suggest finding a good reference on MSDN or just following along with what you see
in the System namespace.

For instance, DataGrid and DataGridTextBox are in the same namespace but not nested. I would do the same.

--
Dave Sexton
(e-mail address removed) (remove BYE-SPAM)
[Please do not reply by email unless asked to]
-----------------------------------------------------------------------

I am creating a custom datagrid based, in part, from someone else's code. The author declared a derived datagrid class in a windows
form, then declared a derived ColumnStyle class, in the same form, that accepted his custom grid type as an argument. For example:

public class HisCustomGrid : DataGrid {
public HisCustomGrid() { } }

public class HisColumnStyle : DataGridTextBox {
public HisColumnStyle(int anyint, HisCustomGrid grid) { } }

I now have a Windows Control Library with all the features I need, but I still need to include the column styles. I'm not sure how
to go about doing this.

1. I think the 'right' way to go would be the columnstyles as a nested class within my custom datagrid class, but I'm not sure how
to direct the columnstyle to my grid. For example:

public class MyCustomGrid : DataGrid {
public MyCustomGrid() { }
public class MyColumnStyle(int colIndex, ???what here???) { } }

2. I assume the other option is to add it as a separate class within my Windows Control Library namespace, but I still don't know
how to make it act upon my custom grid. For Example:

namespace MyCustomGrid {
public class MyCustomGrid : DataGrid {
public MyCustomGrid() { } }

public class MyColumnStyle : DataGridTextBoxColumn {
public MyColumnStyle(int colIndex, ???what here???) { } } }

Any help would be greatly appreciated.

- carl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top