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

RadOpenFileDialog

5 Answers 554 Views
FileDialogs
This is a migrated thread and some comments may be shown as answers.
Kashif
Top achievements
Rank 1
Kashif asked on 01 Sep 2019, 04:36 PM

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.

5 Answers, 1 is accepted

Sort by
0
Kashif
Top achievements
Rank 1
answered on 01 Sep 2019, 06:03 PM

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

Image attached for reference

0
Dimitar
Telerik team
answered on 02 Sep 2019, 06:25 AM

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.
0
Kashif
Top achievements
Rank 1
answered on 04 Sep 2019, 10:06 AM

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?)

0
Kashif
Top achievements
Rank 1
answered on 04 Sep 2019, 10:07 AM
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?)
0
Dimitar
Telerik team
answered on 05 Sep 2019, 01:37 PM

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.
Tags
FileDialogs
Asked by
Kashif
Top achievements
Rank 1
Answers by
Kashif
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or