This is a migrated thread and some comments may be shown as answers.

Fixed column + autosized columns

1 Answer 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
redshift20
Top achievements
Rank 1
redshift20 asked on 15 May 2017, 06:12 PM
I have a gridview with a checkbox column that I would like to remain fixed.. but allow the other columns to auto size.  I'm using the following code:

   gvDocuments.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
   gvDocuments.Columns["Checked"].AutoSizeMode = BestFitColumnMode.None;
   gvDocuments.Columns["Checked"].MaxWidth = 30;
   gvDocuments.Columns["Checked"].MinWidth = 30;
   gvDocuments.Columns["Checked"].Width = 30;
  
   gvDocuments.Columns["Filename"].Width = 300;
   gvDocuments.Columns["Description"].Width = 300;
   gvDocuments.Columns["DocumentTypeDescription"].Width = 135;
   gvDocuments.Columns["DocumentDate"].Width = 135;

 

If you look in the attached screenshot, there is a space between the "Checked" column and the "Description" column.  I'm not sure what I'm doing wrong.

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 May 2017, 08:40 AM
Hello Chris, 

Thank you for writing.  
 
You can set the AutoSizeColumnsMode property to Fill and specify the MinWidth and MaxWidth properties of the column to the desired width. Thus, the column will fill the entire grid's width and the column will have a fixed size: 
public RadForm1()
{
    InitializeComponent();
 
    this.radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
    this.radGridView1.Columns["Discontinued"].MinWidth = 20;
    this.radGridView1.Columns["Discontinued"].MaxWidth = 20;
}

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
redshift20
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or