Is it possible to disable the OpenFileDialog cancel button?
Is it possible to set the OpenFileDialog'开发者_StackOverflow中文版s cancel button enable = false? If so, How?
I'm using winforms
Edit
OpenFileDialog file_open_dialog = new OpenFileDialog();
I don't believe so, and with good reason! Are you sure that you want to disable the Cancel button? Being that this is a modal dialog this would prevent the user from continuing (and hence making your application unusable) until they selected a file - there are almost certainly going to be scenarios where this simply isn't possible, or the user doesn't want to be forced into saving a file.
Of course I could be wrong and there could be a completely legit scenario that I'm not aware of - however I'm afraid that Microsoft were also unaware of this scenario and so the OpenFileDialog doesn't support disabling the cancel button.
I'm afraid that if you really don't want a cancel button you will need to create your own clone of the dialog.
handle the cancel in a loop if you want? might frustrate users ;)
do
{}
while (openFileDialog1.ShowDialog() != DialogResult.OK);
精彩评论