我有Form
编程创建的控件。其中之一是WebBrowser
,它显示验证码图像。用户然后在文本框中输入验证码,如果错误,表单应该用新的验证码图像刷新。我试图Form.Refresh()
然后再调用DisplayCaptcha()
,但它没有工作,所以我解决它就像这个(简化)代码:重新加载或刷新WebBrowser控件和表格一般
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
DisplayCaptchas();
}
private void DisplayCaptcha()
{
string captcha = "<style>html, body{{padding:0; margin:0 }}</style>" +
"<img src=\"http://www.reddit.com/captcha/{0}.png\"></img>";
WebBrowser webBrowserNofap = new WebBrowser();
webBrowserNofap.DocumentText = String.Format(captcha, iden);
......//rest of the code
}
private void button1_Click(object sender, EventArgs e)
{
if (wrongCaptcha)
{
this.Close();
Form3 form3 = new Form3(); //this is how I solved the refreshing
form3.Show();
}
else
{
Form4 form4 = new Form4();
this.Close();
form4.Show();
}
}
}
它的工作原理,但这不是真正的清爽。我想再次删除控件然后DisplayCaptcha()
,但不知道如何做到这一点。 总之,除了关闭然后重新加载Form
之外,还有其他解决方案吗?
你不能调用WebBrowser控件的Refresh方法吗? – rene 2013-02-24 16:44:16
哪里?如果我在DisplayCaptcha()中调用id;它不工作。 – cikatomo 2013-02-24 19:38:16