Link to home
Start Free TrialLog in
Avatar of mphillip85
mphillip85Flag for United States of America

asked on

VB .NET 2003 Datatable trying to autosize column before assigning table to datagrid1.datasource

Here is my code below, what can I do to autosize the columns?

Dim workTable As DataTable
        Dim workCol As DataColumn
        Dim TableCell As DataTable
        Dim tempRow As DataRow
        Dim mySplash As New Splash
        Dim Counter As Integer = 0

        workTable = New DataTable("TrueUp_Reporting")

        workTable.Columns.Add("Business Name")
        workTable.Columns.Add("LDC Account Number")
        workTable.Columns.Add("Rate Code")
        workTable.Columns.Add("Read Date", GetType(Date))
        workTable.Columns.Add("Therms", GetType(Double))
        workTable.Columns.Add("PGE Price", GetType(Double))
        workTable.Columns.Add("RDWD Est Price", GetType(Double))
        workTable.Columns.Add("RDWD Act Price", GetType(Double))

        Me.ProgressBar1.Minimum = 0
        Me.ProgressBar1.Maximum = Me.DS_TrueUpReporting.TrueUp_Reporting.Rows.Count

        For Counter = 0 To Me.DS_TrueUpReporting.TrueUp_Reporting.Rows.Count - 1

            Me.ProgressBar1.Value = Counter

            tempRow = workTable.NewRow

            tempRow(0) = Me.DS_TrueUpReporting.Tables("TrueUp_Reporting").Rows(Counter).Item("Name")


        Me.DataGrid1.DataSource = workTable

Avatar of Arthur_Wood
Flag of United States of America image

you can't.  You would need to control the columns in the DtaGrid, not in the DataTable.

Avatar of mphillip85


Well that was quick.  Thanks.  But just to ask since your rank is genius.  What is your thought on when I connect locally with my program, I run it against 4 million records.  So, I make sure the querys are on the server side.

What would be the biggest issue you can see when I connect local it takes 1 minute or 2 to get info back, where I connect through the internet it takes 5 times or more longer to get the info displayed/results.

I have upload speed for SQL server of 768.  

After you reply I will end the question and give you the points.  Thanks


There is 2 options

1) apply a table style on the fly to the datagrid

2) How do I autosize the columns in my DataGrid so they always fill the the grid's client area?
   all columns in the grid
   1 column in the grid

why are you pulling 4 MILLION records.  Surely you do not expect your users to scroll through that much data.  Is there not some way to allow the user to restrinct the actual number of records to be returned?  What is the nature of the application, and the data.

Hi Hi ,,,,who does have the time to study 4 million records  ?  and why would one do that ??? -:)

Avatar of Arthur_Wood
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Sorry my humor was inappropriate. Please accept my appollegies.
vbturbo, my comment was not directed to you, but to mphillup85.  No offense taken.  In fac, I agree 100% with your comment. Pulling 4 million recors is outrageous, and an insult to the user.
The user actually wants to process all records in detail, down to the lowest records.  So I am calculating from large table backwards.  So my method is reverse.   It took 3 days to process.  Of course, one problem I have, is that the tables have no indexes or primary keys.  I can only copy/import the data.  Limited rights to information till I have a copy, but I copy it everyday.  So I delete, create, import all the time.  Losing the keys/indexes all the time.