DataGrid Shrinking Problem

  • Thread starter Chandra Kotha via .NET 247
  • Start date
C

Chandra Kotha via .NET 247

Hi Guys,

I have a DataGrid For Which Gets its Values From the dataset Perfectly.

The Problem is If The Dataset reurns few Rows like 3 or 4 Rows The Remaining Space in the datagrid. What I want Is Depending on the number of Rows I want to resize my datagrid to exactly Fit the Rows

Ex: If 3 Rows Set DataGrid Size Automatically
If 10 Rows Set it to Fit 10 Rows

Thanks in Advance
 
G

Guest

I did this myself by just calculating a height for the datagrid as a function
of the number of rows in the dataset (DataTable, to be more specific). Here's
some psuedo-code

DataGrid dataGrid1 = new DataGrid();

int rowHeight = 18; // 18 works for me, based
on fonts, etc
// there's
probably a programatic way to determine
// the height of
a row.
int offset = ( rowHeight * dt.Rows.Count ); // dt is a previously created
DataTable
dataGrid1.Height = 23 + offset; // increase the height for each row, 23
accounts for
// the
column headers

Hope this helps,
Tyson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top