NOTE:-
NOTE:-
NOTE:-
CODE:
using System;
using System.Windows.Forms;
namespace ListBoxMultiColumn
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void LaodButton_Click(object sender, EventArgs e)
{
ListBox1.Items.Clear();
ListBox1.MultiColumn = MultiColumnCheckBox.Checked;
if (NumTextBox.Text.Trim() != string.Empty)
{
bool success = Int32.TryParse(NumTextBox.Text.Trim(), out int num);
if (success)
{
int result;
for (int i = 1; i <= 100; i++)
{
result = i * num;
string mult = string.Format("{0} * {1} = {2}", i, num, result);
ListBox1.Items.Add(mult);
}
}
else
{
MessageBox.Show("Please enter a valid number.", "Required", MessageBoxButtons.OK);
NumTextBox.Focus();
}
}
else
{
MessageBox.Show("Please enter a number.", "Required", MessageBoxButtons.OK);
NumTextBox.Focus();
}
}
}
}
No comments:
Post a Comment