By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,815 Members | 1,066 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,815 IT Pros & Developers. It's quick & easy.

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

P: 1
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

Expand|Select|Wrap|Line Numbers
  1. a = cmbSheets.Text.ToString()
  2.         Label2.Text = a
  3.         oleDA = New OleDbDataAdapter("select * from [" & Me.Label2.Text & "]", connExcel)
  4.         Dim sh As Integer
  5.         'grid.AutoSize = True
  6.         a = cmbSheets.Text.ToString()
  7.         Label2.Text = a
  8.         ds.BeginInit()
  9.         oleDA.Fill(ds)
  10.  
  11.         sh = grid.RowCount
  12.         grid.DataSource = ds.Tables(0)
  13.  
  14.         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?
Oct 4 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.