By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,457 Members | 1,294 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,457 IT Pros & Developers. It's quick & easy.

Proper way to handle ColumnStyle for Custom DataGrid?

P: n/a
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
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
ds*************@somethingdigitalBYE-SPAM.com (remove BYE-SPAM)
[Please do not reply by email unless asked to]
-----------------------------------------------------------------------

"Vagabond Software" <carlfenley-X-@-X-san.rr.com> wrote in message news:u9**************@TK2MSFTNGP09.phx.gbl...
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
Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.