Adjust columns in detail view

2 posts, 0 answers
  1. Jeff
    Jeff avatar
    62 posts
    Member since:
    Apr 2012

    Posted 26 Jul 2019 Link to this post

    When using the detail view, the default column width is too wide. Is it possible to set the width before the dialog is shown?

    I would also prefer that the column header text be left justified.

    The first image shows how it looks now and the second image shows how I want it to look.

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3993 posts

    Posted 29 Jul 2019 Link to this post

    Hello, Jeff,   

    Note that the file dialogs use a RadListView in the explorer control for displaying the folders/files. If you need to customize the alignment of the Name header cell, it is suitable to use the CellFormatting event that RadListView offers.

    As to the column's width, it is necessary to specify the Width of the column in the SaveFileDialogForm.Shown event. Please refer to the following code snippet:

    public RadForm1()
    {
        InitializeComponent();
     
     
        this.radSaveFileDialog1.SaveFileDialogForm.Shown += SaveFileDialogForm_Shown;
        this.radSaveFileDialog1.ShowDialog();
    }
     
    private void SaveFileDialogForm_Shown(object sender, EventArgs e)
    {
        this.radSaveFileDialog1.SaveFileDialogForm.ExplorerControl.FileBrowserListView.CellFormatting -= FileBrowserListView_CellFormatting;
        this.radSaveFileDialog1.SaveFileDialogForm.ExplorerControl.FileBrowserListView.CellFormatting += FileBrowserListView_CellFormatting;
        this.radSaveFileDialog1.SaveFileDialogForm.ExplorerControl.FileBrowserListView.ViewType = ListViewType.DetailsView;
        this.radSaveFileDialog1.SaveFileDialogForm.ExplorerControl.LayoutType = Telerik.WinControls.FileDialogs.LayoutType.Details;
        this.radSaveFileDialog1.SaveFileDialogForm.ExplorerControl.FileBrowserListView.Columns["Label"].Width = 100;
    }
     
    private void FileBrowserListView_CellFormatting(object sender, ListViewCellFormattingEventArgs e)
    {
        if (e.CellElement.Data.HeaderText == "Name")
        {
            e.CellElement.TextAlignment = ContentAlignment.MiddleLeft;
        }
        else
        {
            e.CellElement.ResetValue(LightVisualElement.TextAlignmentProperty, Telerik.WinControls.ValueResetFlags.Local);
        }
    }

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 
     
    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top