locked
Datagidview not show image full in datagridview why RRS feed

  • Question

  • Datagidview not show image full in datagridview it show part from image

    not full image why

    Friday, July 4, 2014 2:22 PM

Answers

  • Hi,

    You can use DataGridView.AutoResizeColumns Method and DataGridView.AutoResizeRows Method:

     public void PopulateDataGridView()
            {
                // Add columns to the DataGridView.
                dataGridView1.ColumnCount = 2;
                dataGridView1.Columns[0].HeaderText = "Last Name";
                dataGridView1.Columns[1].HeaderText = "City";
                // Put the new columns into programmatic sort mode
                dataGridView1.Columns[0].SortMode =
                    DataGridViewColumnSortMode.Programmatic;
                dataGridView1.Columns[1].SortMode =
                    DataGridViewColumnSortMode.Programmatic;
               
                // Populate the DataGridView.
                dataGridView1.Rows.Add(new string[] { "Parker", "Seattle" });
                dataGridView1.Rows.Add(new string[] { "Watson", "Seattle" });
                dataGridView1.Rows.Add(new string[] { "Osborn", "New York" });
                dataGridView1.Rows.Add(new string[] { "Jameson", "New York" });
                dataGridView1.Rows.Add(new string[] { "Brock", "New Jersey" });
                DataGridViewImageColumn img = new DataGridViewImageColumn();
                Image image = Image.FromFile(@"C:\\Users\\v-jime\\documents\\visual studio 2013\\Projects\\WindowsFormsApplication5\\WindowsFormsApplication5\\image.png");
                img.Image = image;
                dataGridView1.Columns.Add(img);
               
                img.HeaderText = "Image";
                img.Name = "img";
                dataGridView1.AutoResizeColumns();
                dataGridView1.AutoResizeRows();
             
               
            }
    
    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.


    • Edited by Anne Jing Monday, July 7, 2014 7:40 AM edit
    • Marked as answer by Anne Jing Friday, July 11, 2014 8:48 AM
    Monday, July 7, 2014 7:39 AM