I am very very new to C# and I am in the process of doing my project for my studies using Winforms. The below code is not doing its work. When my richComResults (richTextBox) is empty, I want a messageBox to appear and says "There is nothing to be cleared!", but it doesn't say it, it shows the Yes/No dialog.
Please could you be kind enough to point out my mistakes? Your input would be very much appreciated. Thank you.
private void btnComClearAll_Click(object sender, EventArgs e)
{
if (richComResults == null)
{
MessageBox.Show("There is nothing to be cleared!");
}
if (richComResults != null)
{
DialogResult dialogResult = MessageBox.Show("Are you sure you want to clear the results?", "Warning", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
richComResults.Clear();
}
else if (dialogResult == DialogResult.No)
{
}
}
}