Answer the question
In order to leave comments, you need to log in
How to make sure that when clicking on the button5 button, the window that should open does not open due to an error?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Генератор
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
this.FormBorderStyle = FormBorderStyle.None;
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Application.Exit();
}
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.Hide();
Form2 f = new Form2();
if (f.ShowDialog() == DialogResult.OK)
f.Show();
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Text = clearWord(textBox1.Text);
textBox2.Text = clearWord(textBox2.Text);
if ((checkBox1.Checked = false) && (checkBox2.Checked = false) && (checkBox3.Checked = false))
{
MessageBox.Show("Выберите уровень для вашего будущего домена", "Ошибка",
MessageBoxButtons.OK);
}
List<string> keyWords = new List<string>();
if (textBox1.Text != "") keyWords.Add(textBox1.Text);
if (textBox2.Text != "") keyWords.Add(textBox2.Text);
List<string> domainZoneEn = new List<string>();
if (checkBox1.Checked)
domainZoneEn.Add("ru");
if (checkBox2.Checked)
domainZoneEn.Add("su");
List<string> domainZoneRu = new List<string>();
if (checkBox3.Checked)
domainZoneRu.Add("рф");
this.Hide();
Form7 f = new Form7(keyWords, domainZoneEn, domainZoneRu);
if (f.ShowDialog() == DialogResult.OK)
f.Show();
}
private string clearWord(string word)
{
return String.Join("", word.Split('@', ',', '.', ';', '\'', '\"', ' ', '-', '_', '#', '$', '!', '%', '^', '(', ')', '{', '}', '[', ']', '\\'));
}
private void button7_Click(object sender, EventArgs e)
{
this.Hide();
Form2 f = new Form2();
if (f.ShowDialog() == DialogResult.OK)
f.Show();
}
private void button6_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
Answer the question
In order to leave comments, you need to log in
What error are you talking about?
Wrap the code inside button5_Click in a try/catch.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question