Looking for an Elegant "Dont Show Me This Dialog Again" Dialog in C#
I've been looking for a dialog with a checkbox "Don's show me this dialog ag开发者_C百科ain" in C#.
I googled and search a lot, but I just could not find an elegant solution.
The dialog should work as similar as the native MessageBox.Show, but with a new property value (bool value) return to the caller.
Thanks.
Vista and Windows 7 applications can use the new TaskDialog features which extend the standard MessageBoxes to support a checkbox at the bottom (along with all sorts of other goodies such as Command Links, custom button text, footers etc).
Unfortunately from C# you need to do some interop to access this. If you just want the advanced TaskDialogs to target Vista/Windows 7, use the WindowsAPICodePack from http://code.msdn.microsoft.com/WindowsAPICodePack which can handle the interop complexity for you.
If you need to support XP, there is an excellent wrapper that supports the native TaskDialogs on Vista/7 with a WinForms fallback for XP here: http://www.codeproject.com/KB/vista/Vista_TaskDialog_Wrapper.aspx
Why don't you create your own. It is a very simple one. Just derive from System.Windows.Forms.Form
class and mimic it like the one you want.
I don't feel there will be a readymade solution as such. For implementing "Do not show me again", you need to persist the information outside the dailog and also create a user profile.
If your infrastructure of persisting the user profile is there, you can simple create a class similar to the messagebox
class. You can not derive from messagebox
however.
精彩评论