IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New On to the future!

The .Net 2.0 DataGridView has options for autosizing columns based on content or by setting relative weights for each column. It also doesn't do the hierarchical thing so you have one less level of abstraction to worry about


I looking forward to convincing my boss to go to .Net 2.0, so I don't have to keep jumping through these hoops. He'll probably agree, as long as it doesn't cost us too much out-of-pocket.

BTW, I tried your code suggestions - it still doesn't work. Pisser.

lincoln

"Chicago to my mind was the only place to be. ... I above all liked the city because it was filled with people all a-bustle, and the clatter of hooves and carriages, and with delivery wagons and drays and peddlers and the boom and clank of freight trains. And when those black clouds came sailing in from the west, pouring thunderstorms upon us so that you couldn't hear the cries or curses of humankind, I liked that best of all. Chicago could stand up to the worst God had to offer. I understood why it was built--a place for trade, of course, with railroads and ships and so on, but mostly to give all of us a magnitude of defiance that is not provided by one house on the plains. And the plains is where those storms come from." -- E.L. Doctorow


Never apply a Star Trek solution to a Babylon 5 problem.


I am not merely a "consumer" or a "taxpayer". I am a Citizen of the United States.


[link|mailto:bconnors@ev1.net|contact me]
New Might take a look at this too
Be aware (beware) that VS.Net 2005 is somewhat designed for SQL Server 2005. It sounds like you can still use it with SQL Server 2000, but I don't know what pitfalls await there (MS tying products together?!? Shocking!). ASP.Net 2.0 is quite different from ASP.Net 1.1 as well. Fortunately you can run VS.NET 2003 and VS.NET 2005 side by side.

If you can solve whatever other problems you are having with the DataGrid, here's how to do autosizing of columns with the DataGrid: [link|http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c44c.aspx#q877q|http://www.syncfusio...Q_c44c.aspx#q877q] That FAQ is a good reference overall for WinForms programming.

In case we missed something else, here's the code based on yours that worked for me with a empty form on which I dropped a DataGrid named DisplayGrid and a OleDbConnection named objCon. I also used an Access DB instead of SQL Server. And I've excised the designer generated code (which BTW, is where all that point and click config of the DataGrid from my original solution would appear as code).

\nPublic Class Form1\n    Inherits System.Windows.Forms.Form\n\n#Region " Windows Form Designer generated code "\n...\n#End Region\n    Dim MyDataAdapter As System.Data.OleDb.OleDbDataAdapter\n    Dim MyDataset As System.Data.DataSet\n\n    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load\n        Dim strSQL As String\n\n        strSQL = "SELECT DISTINCT ProductCode, ProductName FROM Products"\n        strSQL = strSQL & " WHERE ProductName IS NOT NULL ORDER BY ProductName"\n        MyDataAdapter = New System.Data.OleDb.OleDbDataAdapter(strSQL, objCon)\n        MyDataset = New DataSet("ProductsDataset")\n        MyDataAdapter.Fill(MyDataset, "Products")\n        DisplayGrid.DataSource = MyDataset.Tables("Products")\n\n\n        Dim myGridStyle As DataGridTableStyle = New DataGridTableStyle\n        myGridStyle.MappingName = "Products"\n        ' \n        '     The ProductCode is a 3 byte varchar field \n        ' \n        Dim myFirstColumn As DataGridColumnStyle = New DataGridTextBoxColumn\n        myFirstColumn.MappingName = "ProductCode"\n        myFirstColumn.HeaderText = "Code"\n        myFirstColumn.Width = 40\n        myFirstColumn.Alignment = HorizontalAlignment.Center\n        ' \n        '     The ProductDesc is a 50 byte varchar field \n        ' \n        Dim mySecondColumn As DataGridColumnStyle = New DataGridTextBoxColumn\n        mySecondColumn.MappingName = "ProductName"\n        mySecondColumn.HeaderText = "Name"\n        mySecondColumn.Width = 400\n        mySecondColumn.Alignment = HorizontalAlignment.Left\n\n\n        myGridStyle.GridColumnStyles.Add(myFirstColumn)\n        myGridStyle.GridColumnStyles.Add(mySecondColumn)\n\n\n        DisplayGrid.TableStyles.Add(myGridStyle)\n    End Sub\nEnd Class\n


Good luck!
--
Chris Altmann
New VS 2005 (.NET 2.0) cost depends on the level
Professional isn't too bad (<$500/seat upgrade), and I guess Enterprise Developer (VS2005 ED) might not be too bad if you're already paying for MSDN Premium, otherwise it's way more expensive than before - at about $2300/seat upgrade - since you have to get it with MSDN Premium.

VS2005 Enterprise Kitchen Sink is about $10,000/seat, not including the various server thingies (TeamServer?)

We have VS2001 Enterprise Developer, looked at the price to upgrade to VS2005 ED, laughed, and upgraded to VS2005 Professional. I saw no value in VS2005 ED, since all the interesting extras have open source equivalents that are probably better (e.g. Subversion for version control, NUnit for unit testing).

The big advantage of .NET 2.0 is, of course, being able to run IronPython.

--Tony
     Datagrids suck/don't suck in .NET - (lincoln) - (17)
         They do suck, but try this - (altmann) - (16)
             So this is easier than writing your own HTML? -NT - (drewk) - (1)
                 To create a editable grid in a Windows program? Yes. -NT - (altmann)
             That worked, but I prefer to do things in code - (lincoln) - (13)
                 Like I said, this (datagrids) is easier than writing code? -NT - (drewk) - (6)
                     Oh, come the heck on! Six or eight drop-down selections! - (CRConrad) - (5)
                         My experience with it - (drewk) - (3)
                             Again, we're talking about client side Windows apps here. -NT - (altmann) - (2)
                                 Come on, let me slam Winders, please? - (drewk) - (1)
                                     Like shooting fish in a barrel - (ChrisR)
                         BTW, I just checked: In Delphi, it's zero properties to set. - (CRConrad)
                 So do that. - (altmann) - (5)
                     You're overlooking - (lincoln) - (4)
                         You've got your mappings wrong - (altmann) - (3)
                             On to the future! - (lincoln) - (2)
                                 Might take a look at this too - (altmann)
                                 VS 2005 (.NET 2.0) cost depends on the level - (tonytib)

I am LRPD, millionaire. I own a mansion and a yacht.
46 ms