MaterialSkin icon indicating copy to clipboard operation
MaterialSkin copied to clipboard

Form not returning DialogResult because of matTextBox as psw with data

Open TomsDev67 opened this issue 5 years ago • 5 comments

Hi,

I got another funny bug the last week. When your Form that you show with the method xxx.ShowDialog() contain a TextBox with the property password to true and if you have some text inside, you'll never receive back the DialogResult in your parent

Steps : In your program.cs open a form like this

var form = new Form1();
var result = form.ShowDialog() == DialogResult.OK;

In your form, add a TextBox with the password property = true

If your TextBox contain any text when you call

this.DialogResult = DialogResult.OK/Cancel;
Close();

So your program will never get back the result.

The only workaround I find is to call something like materialTextBoxPassword.Text = string.Empty;

TomsDev67 avatar Mar 09 '20 09:03 TomsDev67

Hi, thanks for reporting, it's really nice to get feedback from users :)

Weird that's happening, Excluding the work around I do to sync the text caret, I don't do anything special with the textbox when it's on password mode. It's working for me, see: dialog

On your dialog, did you initialize the Material Form correctly? this is my code for it: image

And on the example app, I call it like this: image

leocb avatar Mar 09 '20 11:03 leocb

Damn it's just incomprehensible :-S

I've tried to replace var result = form.ShowDialog() == DialogResult.OK; per var result = form.ShowDialog(); like in your example but i've the same behavior as before.

The 2 only difference I see between your test and mine is :

  • My test project is in 4.7.2 instead of 4.6.1
  • I'm using NuGet package and not the library directly

But for me both things have no impact on something like that 8-/

TomsDev67 avatar Mar 09 '20 12:03 TomsDev67

Strange indeed, I have no ideia what could be causing it. do you have events on your password textbox? are you reading it somewhere? connected to a db? every little detail could help.

I'm marking this as a bug as I received another report on components not being disposed correctly (#65) so maybe this has something to do with it. I've not encountered this myself, but I'll keep my eye on it

leocb avatar Mar 09 '20 13:03 leocb

I've done some other tests.

It is working like a charm in 4.6.1 .NET project but not in 4.7.2 project (using in both MaterialSkin compiled in 4.6.1) I don't know why but yeah. (It is an empty project in which I've reproduced the issue)

To complete test, I've tried with a TextBox from legacy Winform having the property "UseSystemPasswordChar" to true and no issue with this component.

TomsDev67 avatar Mar 09 '20 14:03 TomsDev67

That's very interesting. Thanks for reporting, I'll take a look at it

leocb avatar Mar 09 '20 15:03 leocb