Custom Dialog

D

deciacco

VS2k5 - C# .NET 2

I would like to create my own custom dialog that behaves like the
FolderBrowserDialog. In other words, I would like to be able to go to the
ToolBox, select my custom dialog and drop into my form designer. Then set
some properties from within code before calling the showDialog method. I'm
not trying to recreate the FolderBrowserDialog. Just my own custom dialog
that captures some data.

example:
this.customDialog.customProperty = false;
this.customDialog.customProperty2 = 5;
this.customDialog.showDialog(this);
this.textBox1.text = this.customDialog.getValue();

Thanks.
 
N

Nicholas Paldino [.NET/C# MVP]

The best way to do this would be to create a class that derives from
CommonDialog, and then override the RunDialog method to show your dialog
when it is called.

See the documentation for the CommonDialog class (in the
System.Windows.Forms namespace) for more information on how to do this.

Hope this helps.
 
D

deciacco

This is what I have so far, but when I go to view it in the designer I get
this error:
"The designer must create an instance of type
'System.Windows.Forms.CommonDialog' but it cannot because the type is
declared as abstract."

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace MyControls
{
public sealed class MyDialog : CommonDialog
{
public MyDialog()
{

}

public override void Reset()
{

}

protected override bool RunDialog(IntPtr hWndOwner)
{
return true;
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top