Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);
            }
        }
Posted
Updated 14-Oct-11 0:20am
v3

 
Share this answer
 
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.
 
Share this answer
 
Comments
SREENATH GANGA 14-Oct-11 6:11am    
no its not working my friend

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900