Results 1 to 7 of 7

Thread: Limiting the DataGridView Rows!!!

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2009
    Posts
    1,103

    Unhappy Limiting the DataGridView Rows!!!

    I had a DataGridView in which i want to fetch the data from the access database,so i did this code:
    Code:
     Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Etech.mdb"
    
            Dim myConnection As OleDbConnection = New OleDbConnection
    
            myConnection.ConnectionString = connString
    
            Dim da As OleDbDataAdapter = New OleDbDataAdapter("Select LAcNo,IssuerName,Creditor,Amount,ROI,EMIAmount,BankAcNo,CreditCardNo,Notes from MLoan", myConnection)
    
            Dim ds As DataSet = New DataSet
    
            DataGridView1.Columns(0).DataPropertyName = "LAcNo"
    
            DataGridView1.Columns(1).DataPropertyName = "IssuerName"
    
            DataGridView1.Columns(2).DataPropertyName = "Creditor"
    
            DataGridView1.Columns(3).DataPropertyName = "Amount"
    
            DataGridView1.Columns(4).DataPropertyName = "ROI"
    
            DataGridView1.Columns(5).DataPropertyName = "EMIAmount"
    
            DataGridView1.Columns(6).DataPropertyName = "BankAcNo"
    
            DataGridView1.Columns(7).DataPropertyName = "CreditCardNo"
    
            DataGridView1.Columns(8).DataPropertyName = "Notes"
    
            da.Fill(ds, "MLoan")
    
            Dim dt As New DataTable
    
            da.Fill(dt)
            
            DataGridView1.DataSource = dt
    Now after fetching the data from the database to the DataGridView,i want to remove those columns of the DataGridView where the columns does not contain any value;
    i.e,the columns with no contents......
    Initially my design form looks like this:
    Attachment 73025
    After the load button click it looks like this:
    Attachment 73026
    In the above snapshot,after fetching the data from the access database to the DataGridView,i want to remove the PplicyHolderName,PremiumAmount and a few other columns since these are the columns which do not contain any data....
    How to do this?
    Thank you
    Last edited by gautamshaw; Feb 21st, 2010 at 01:21 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width