Datagrid View Problem : Datagrid is Taking a Minimum size of 12 automatically!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tarunisme
    New Member
    • Oct 2013
    • 1

    Datagrid View Problem : Datagrid is Taking a Minimum size of 12 automatically!!

    I have A datagrid which is filled by a dataset which takes an excel sheet as input.

    My problem is that when my grid is initialized as run time It is empty, but as soon as my dataset goes in the grid, the grid.rowcount goes to minimum of 12 even when my dataset has only 3 entries.

    here is the part of code

    Code:
    a = cmbSheets.Text.ToString()
            Label2.Text = a
            oleDA = New OleDbDataAdapter("select * from [" & Me.Label2.Text & "]", connExcel)
            Dim sh As Integer
            'grid.AutoSize = True
            a = cmbSheets.Text.ToString()
            Label2.Text = a
            ds.BeginInit()
            oleDA.Fill(ds)
    
            sh = grid.RowCount
            grid.DataSource = ds.Tables(0)
    
            sh = grid.RowCount
    the first value of sh is 0

    then after the datasource is defined the value goes to 12. The ds has a excel sheet with only 4 rows. I just don't get it!!

    Because of this problem my program is limited to read only those excel sheets which have 12 or more than 12 rows.
    Please HELP!!
    what is the solution to this problem?
    Last edited by Rabbit; Oct 4 '13, 03:12 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
Working...