If you want to place the code into a separate dll do the following:
- In your solution, add a new class library project for creating your dll
- In that newly created project, add a reference to
System.Windows.Forms
- Add the code for customizing the
OpenFileDialog
to the class library project
- In your main Windows Forms project add a (project) reference to your class library
However, please note that as long as you only wish to use the customized file dialog within a single application, it is not required that this code lives in a separate dll. You can simply create a class with all the customization in your main project and re-use that class in all forms:
class SpecializedOpenFileDialog
{
private OpenFileDialog ofd = new OpenFileDialog();
public SpecializedOpenFileDialog()
{
ofd.Multiselect = false;
ofd.Filter = "*.html";
}
public DialogResult ShowDialog()
{
return ofd.ShowDialog();
}
public string FileName
{
get
{
return ofd.FileName;
}
}
}