Fog Creek Software
Discussion Board




.NET Forms Datagrid has made me physically sick

I wonder if I can sue MS for workplace stress?

Three days ago I started the mind numbingly simple(supposedly) task of populating a collection (of business expenses) and putting them in a datagrid, the only requirement was that the user could click on a column heading and sort by that column and there were a few visual things such as the color of the row depending upon how big the expense was. So I learned about the datagrid and assigning datasources and sorting columns etc.

Then came the bit about making a row a different color if, for example, objExpense.AmountOwed <> 0, and I've got to say that it took me about 1.5 days to get this to work.
I hope I'm not stupid, but the effort involved was simply astounding. Resulting in a headache and a vague nausea.
Simply finding an example took hours of web searching.
Even now I think my solution is 'kludgy'.

I've done similiar things with TrueGrid, MSFlexgrid, Janus, VSFlexgrid etc and it's a trivial exercise, I think the TableSyles collection is an elegant burden. I think the older paradigm served us better, even though it's not PC to say it.

I know I could have used any of these other grids but I wanted vanilla .NET, and I payed for it with nausea.

Realist
Friday, June 20, 2003

PS - I'm not sure what my point is.

Realist
Friday, June 20, 2003

Infragistics DataGrid for .Net costs $500. You spent twelve hours on one basic thing. If your time is worth more than $40/hr you would've paid for it already (okay, different learning curve, granted).

It's a free (albeit huge) download - try it out.

Philo

Philo
Friday, June 20, 2003

A general warning to beware of Infragistics components. We found them to be EXCEEDINGLY heavy on the wire, both in HTML content and their use of ViewState. One of their demos (for a tree control, if memory serves), generated a 2MB response page (800KB of ViewState and 1.2MB of HTML).

That's SERIOUSLY BLOATED.

Brad Wilson (dotnetguy.techieswithcats.com)
Saturday, June 21, 2003

I found the same thing with Infragistics. They look great but some at a huge cost.

ComponentOne seems to be a bit better in this regard.

Marc
Saturday, June 21, 2003

Hrm. I read that the issue was winforms, but looking at the post, now I don't know why I got that idea - he doesn't say.

If it's web forms, then all that stuff is easy once you understand The Way Of The Datagrid.

Philo

Philo
Saturday, June 21, 2003

"Zen & The Way of The Datagrid" by Philo

:-)

Marc
Saturday, June 21, 2003

You might want to check out DevExpress components.

They have a .net data grid component called XtraGrid
http://www.devexpress.com/products/net/xtragrid/index.asp

Cletus
Saturday, June 21, 2003

Yes the datagrid in Winforms is a bit different, it has slightly less functionality than ASP datagrid.
Basically I got it all to work, but it was way, way too much buck for the bang. I'd be interested to know if the MS Datagrid is getting used much or if people are turning away from it. Then again, it could always just be my problem.

Realist
Saturday, June 21, 2003

We're using the MS DataGrid.

But that's just because we spent about 2 months straight fixing Microsoft's bugs and making it work the way we need it to work.

Simple examples:  There is no simple event such as "ComittingRow" or something along those lines, which would allow you to keep the user on a particular row if it failed row-level validation (for example, if it's missing one of the required columns.)  We ended up having a custom-code a huge workaround which navigated the user back to the problem row.

Now, there IS a way to have the datagrid display a message and bring the user back to the row they were editing.  There are two problems: 1) the message is hard-coded.  2) it gives the user the option to NOT go back to the row!  How useless if you're checking for required data!

Nasty.

We have been looking for 3rd-party grids, but none has met all of our requirements. Most seem to implement lots of "neat" stuff, but we haven't found any that implement what we need in a simple, straightforward fashion.  The Xceed grid has come the closest.

Knowing what we know now, both about how much time it takes to get the MS grid working the way we want and the limitations of third-party grids, we would have spent that two months writing our own grid.  That would have been the best investment we could have made.

(Note: Our product is heavily grid-based, we have exacting requirements for the user experience with respect to the grid, we need to closely match the user experience of an existing product, our product sells for $6,000 a seat, and our expected product lifetime is five to ten years.)

Just my $0.02.

Dave
Saturday, June 21, 2003

Maybe I'm missing some important detail, but why won't the following work?

void TheGrid_ItemDataBound(Object sender, DataGridItemEventArgs e)
{             
    switch (e.Item.ItemType)
    {
        case ListItemType.Item:
        case ListItemType.AlternatingItem:
            if ((Decimal)DataBinder.Eval(e.Item.DataItem, "AmountOwed") != 0m)
                e.Item.BackColor = System.Drawing.Color.Red;           
            break;
    }
}

SomeBody
Saturday, June 21, 2003

SomeBody: that works for the ASP.NET DataGrid -- I assumed Realist was referring to the WinForms DataGrid (although they refer to it slightly ambiguously as ".NET Forms Datagrid").

Duncan Smart
Sunday, June 22, 2003

Does anyone know of a good tutorial for dealing with the WinForms DataGrid?    I'm beginning on a project using it, and I've had some difficulty myself (not to the point of nausea yet ;-)).

anon
Sunday, June 22, 2003

George Shepherd's WinForms FAQ is great:
http://www.syncfusion.com/FAQ/WinForms/

And there's some good links and stuff here:
http://noiseehc.freeweb.hu/

Duncan Smart
Sunday, June 22, 2003

I've 'almost' got the grid working as I want to.

What I need to do is to allow the user to select multiple rows (they must be colored as selected) as well as some different fonts per row depending upon the value of certain columns.

I thought I had it all worked out and then the user wanted multiple row selections.

This throws the color scheme into kaos. I seem to be working far too hard to achieve what I want.

Realist
Sunday, June 22, 2003

Ah, I read the discussion of viewstate and naturally assumed we were talking about Web Forms.  I guess I should've payed more attention to Realist's posts. 

Still, it's surprising that the Windows Forms version of DataGrid is harder to work with than the Web Forms version.  If you find a solution as straightforward as ItemDataBound, do let us know.

SomeBody
Sunday, June 22, 2003

http://www.syncfusion.com/FAQ/WinForms/default.asp#44

Just me (Sir to you)
Monday, June 23, 2003

Sir, That's a really good site that's helped me quite a lot However I'm far beyond that level now and can't find any truly 'sophisticated' help for the macho 'real man' developer.

Realist
Wednesday, June 25, 2003

Realist,

the great thing is that nowadays you often can get direct access to the developer that owns that code at Microsoft.
While moree and more of them have blogs, most of them seem to follow the newsgroups and jump in when a question is not adequately answered.
Maybe try:
news://news.microsoft.com/microsoft.public.dotnet.framework.windowsforms.databinding

or

news://news.microsoft.com/microsoft.public.dotnet.framework.aspnet.datagridcontrol

alternatively there is a asp.net forum on datagrid, datalist and repeater controls
http://www.asp.net/Forums/ShowForum.aspx?tabindex=1&ForumID=24

or hey, why not ask the Datagrid Girl

http://www.datagridgirl.com/

(Yes, even controls have fan sites nowadays)

Just me (Sir to you)
Wednesday, June 25, 2003

It would be great if somebody wrote a simple class that can change a row/cell color based on some criteria by simply passing the columns and criteria in Winforms for windows applications???? I'll try writing one but if anybody hits gold before that please let us know.

sparkis
Friday, April 30, 2004

*  Recent Topics

*  Fog Creek Home