RadOpenFileDialog

6 posts, 0 answers
  1. Kashif
    Kashif avatar
    66 posts
    Member since:
    Jan 2019

    Posted 01 Sep 2019 Link to this post

    Dear Admins.

    Using the Following code to open the FileDialog.

    private void btnBrowse_Click(object sender, EventArgs e)
    {
        RadOpenFileDialogForm openFileDialog = new RadOpenFileDialogForm();
        openFileDialog.ShowHiddenFiles = false;
        openFileDialog.FilterIndex = 1;
        openFileDialog.Filter = "GIF (*.gif)|*.gif| "+
                     "Bitmap Files (*.bmp)|*.bmp|"+
                     "JPEG (*.jpg; *.jpeg)|*.jpg;*.jpeg|";
        openFileDialog.RestoreDirectory = true;
        DialogResult dr = openFileDialog.ShowDialog();
        if (dr == DialogResult.OK)
        {
            string filePath = openFileDialog.FileName;
        }
    }

     

    But every time when dialog box open Third Option from the Filter List is selected.

    I want to select default first option.

  2. Kashif
    Kashif avatar
    66 posts
    Member since:
    Jan 2019

    Posted 01 Sep 2019 Link to this post

    Why Icon view Not showing the Images in the detail Side.

    Image attached for reference

  3. Dimitar
    Admin
    Dimitar avatar
    2936 posts

    Posted 02 Sep 2019 Link to this post

    Hi Muhammad,

    You can use the Shown event to set the filter manually. Here is the code:

    private void RadButton1_Click(object sender, EventArgs e)
    {
        RadOpenFileDialog openFileDialog = new RadOpenFileDialog();
        openFileDialog.ShowHiddenFiles = false;
        openFileDialog.FilterIndex = 1;
        openFileDialog.Filter = "GIF (*.gif)|*.gif| " +
                     "Bitmap Files (*.bmp)|*.bmp|" +
                     "JPEG (*.jpg; *.jpeg)|*.jpg;*.jpeg|";
        openFileDialog.RestoreDirectory = true;
        openFileDialog.OpenFileDialogForm.Shown += OpenFileDialogForm_Shown;
        DialogResult dr = openFileDialog.ShowDialog();
        if (dr == DialogResult.OK)
        {
            string filePath = openFileDialog.FileName;
        }
    }
    
    private void OpenFileDialogForm_Shown(object sender, EventArgs e)
    {
        var form = sender as RadOpenFileDialogForm;
        var filterDropDown = form.Controls[0].Controls[6] as RadDropDownList;
        filterDropDown.SelectedIndex = 0;
    }
    

    I hope this helps. Should you have any other questions, do not hesitate to ask.

    Regards,
    Dimitar
    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.
  4. Kashif
    Kashif avatar
    66 posts
    Member since:
    Jan 2019

    Posted 04 Sep 2019 in reply to Dimitar Link to this post

    When Use this line

    openFileDialog.OpenFileDialogForm.Shown += OpenFileDialogForm_Shown;

    this error popup.

    'RadOpenFileDialogForm' does not contain a definition for 'OpenFileDialogForm' and no accessible extension method 'OpenFileDialogForm' accepting a first argument of type 'RadOpenFileDialogForm' could be found (are you missing a using directive or an assembly reference?)

  5. Kashif
    Kashif avatar
    66 posts
    Member since:
    Jan 2019

    Posted 04 Sep 2019 in reply to Dimitar Link to this post

    When Use this line

    openFileDialog.OpenFileDialogForm.Shown += OpenFileDialogForm_Shown;

    this error popup.

    'RadOpenFileDialogForm' does not contain a definition for 'OpenFileDialogForm' and no accessible extension method 'OpenFileDialogForm' accepting a first argument of type 'RadOpenFileDialogForm' could be found (are you missing a using directive or an assembly reference?)
  6. Dimitar
    Admin
    Dimitar avatar
    2936 posts

    Posted 05 Sep 2019 Link to this post

    Hello Muhammad,

    I have attached my test project. Could you please check it and let me know how it differs from your real setup? 

    Are you inheriting the dialog class and applying the changes in it? 

    I am looking forward to your reply.

    Regards,
    Dimitar
    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