Adding unbound (template like column in asp.net) columns into DataGrid

J

Josh Thuya

Hi everyone,

I am having some difficulties using datagrid control in
windows forms and I hope some of you guys can help me out
with this.

I have been working on asp.net projects for quite a while
and I am quite happy with the asp.net DataGrid control that
comes with .net framework, especially the template columns
in asp.net DataGrid control. With template columns, we can
host almost any control (DropDownList, TextBox, Label,
DataGrid, Button, etc.) within it. It is so easy to do
that.

Now I got a windows application project and just started
working on it. I am finding it too hard to use windows
form datagrid. I am spending most of my time inheriting
DataGridTextBox column whenever I need to host different
controls (such as ComboBox, Button, etc.) other than
TextBox and CheckBox. Even if I want to hilight a column
based on its value, I need to inherit and override the
paint method. How frustrating that is!

The WORST thing is you cannot add extra column without
having a mapping name, even if you add one, it wont show up
because there is no matching mapping name in the
datasource. That's too bad!! Sometimes, I have a need to
display my own computed column so the values of these
columns dont usually come from the datasource. Another
thing is I am a big fan of objects and custom
collections/Lists so I dont normally use DataTable and
DataSets. I always bind the public properties of my own
business objects with the DataGrid. This is where my
problem is; if there is no public property in the object,
it won't show up in the DataGrid.

I am having difficulties using windowsforms DataGrid and
would like to ask some questions.

So these are my questions:

1. How do I add unbound or template like column into
DataGrid that binds to a custom IList?

2. How can I highlight rows in different color based on the
status of a column (for example, when I display customer
list, I want to highlight all inactive customers in red,
active customers in green, etc.)

3. Is there a template column in windows form Datagrid
(like in asp.net) that can host any control inside it?

The application currently I am working on needs to use
DataGrid intensively and I couldn't concentrate on business
problems but I am spending most of my time customizing the
datagrid. This is very time-consuming and I need
suggestion from those who have already come across this
kinda problems.

Any suggestion?

Thanks
Josh
 
S

Sijin Joseph

1. How do I add unbound or template like column into
DataGrid that binds to a custom IList?

http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q787q

2. How can I highlight rows in different color based on the
status of a column (for example, when I display customer
list, I want to highlight all inactive customers in red,
active customers in green, etc.)

Check this out http://dotnet.leadit.be/extendeddatagrid/ it has a custom
control that allows you to control the formatting of cells.

3. Is there a template column in windows form Datagrid
(like in asp.net) that can host any control inside it?

No.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
 
J

Josh Thuya

Hi Sijin,

Thanks for your info! The extended datagrid looks good.
I will try it out.

Thanks
Josh
 

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