数据网格视图行调整 [英] DATA GRIDVIEW ROW RESIZING
问题描述
亲爱的所有人
在我的应用程序中,我有一个datagridview,并用包含7个字段或列的数据集填充了它.
我的问题是,因为我的表单是全屏模式,所以此datagridviews仅一部分填充了数据,其余部分保持空白(这不是我需要的所有数据都出现的错误,并且其中没有异常或问题,如果datagrid中存在更多列查看它可能已经满了)
我也有一个叫做adress的领域,它可能有多行,我希望它们能够自动调整大小
我的行要填充到datagridview的全部部分中,任何人都可以说出一个主意
我无法使用自动调整大小,因为如果行包含的数据较少,则会自动将其设置为很小的大小
查看我的代码
Dear all
in my application I had a datagridview and I fill that with a dataset with contain 7 fields or columns
my problem is that since my form is fullscreen mode this datagridviews only one part is filled with data and the rest remains blank(its not an error all data i need came and no exception or problem in it, also if more columns were there in datagrid view it might have been fully filled)
I had also a feild called adress which may have multiple lines I want them to be autoresize
and my rows to be filled in total part of datagridview can anyone pls tell an idea
I cannot use autoresize since if rows contain less data it will be made very small size automatically
view my code
private void btnsearch_Click(object sender, EventArgs e)
{
try
{
String query = "Select * from customermastertable where (companyname=''" + txtcustname.Text + "'')";
OleDbDataAdapter dAdapter = new OleDbDataAdapter(query, connString);
DataSet ds = new DataSet();
dAdapter.Fill(ds, "tbluserdataview");
tblcustomerdataview.DataSource = ds.Tables["tbluserdataview"].DefaultView;
tblcustomerdataview.AutoSizeColumnsMode =
DataGridViewAutoSizeColumnsMode.Fill;
}
catch (Exception exp)
{
MessageBox.Show("The application had met with some errors please restart the application :\n error:closer MSAccess files");
Console.WriteLine(exp);
}
}
推荐答案
MSDN帮助您
http://msdn.microsoft.com/en-us/library/ms171604.aspx [ ^ ]
MSDN help you
http://msdn.microsoft.com/en-us/library/ms171604.aspx[^]
使用可以使用 DataGridView.AutoSizeColumnsMode属性
[ ^ ],将其设置为 DataGridViewAutoSizeColumnsMode.Fill [ ^ ].
您可能要使用 DataGridViewColumn.MinimumWidth [ ^ ]以确保该列中的信息是可见的.
Use can use the DataGridView.AutoSizeColumnsMode Property
[^], set it to DataGridViewAutoSizeColumnsMode.Fill[^].
You may want to use DataGridViewColumn.MinimumWidth[^] to ensure the information in the column is visible.
这篇关于数据网格视图行调整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!