how to close a form on messagebox pop up ok display

Posted by Shanky11 under C# on 3/1/2013 | Points: 10 | Views : 1303 | Status : [Member] | Replies : 2
on save details btn i used messagebox.show("Saved Successfully")
On this pop up i want that all filed gets blank
or this close this form




Responses

Posted by: Satyapriyanayak on: 3/1/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
private void button1_Click(object sender, EventArgs e)
{
CleartextBoxes1();
}

public void CleartextBoxes1()
{
foreach (Control Cleartext in this.Controls)
{

if (Cleartext is TextBox)
{

((TextBox)Cleartext).Text = string.Empty;

}

}

}


close this form

this.Close();

If this post helps you mark it as answer
Thanks

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Satyapriyanayak on: 3/1/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Login_page_Msaccess
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
if (MessageBox.Show("clear", "clear", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
CleartextBoxes1();
}
else
{
this.Close();
}
}
public void CleartextBoxes1()
{
foreach (Control Cleartext in this.Controls)
{

if (Cleartext is TextBox)
{

((TextBox)Cleartext).Text = string.Empty;

}

}

}
}
}


If this post helps you mark it as answer
Thanks

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response