Hashirmama Senji
New member
- Joined
- Jun 11, 2014
- Messages
- 2
- Programming Experience
- Beginner
Hello, I am a beginner in C# and I have made a program. Here is the code:
Visual Studio...
This is a multiplication table generator. I have noticed that adding too many rows for listboxes made the program hang. Someone told me that I can use data grid view to overcome that problem. However,since I am a beginner, I need a little help to do that. I have searched internet but they are all codes about how to add SQL data to data grid view.
Any help will be appreciated
C#:
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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double of = 0;
double from = 0;
double to = 0;
double ans = 0;
Table.Items.Clear();
if (double.TryParse(Of.Text, out of) && double.TryParse(From.Text, out from) && double.TryParse(To.Text, out to))
{
for (double i = from; i <= to; i++)
{
ans = i * of;
Table.Items.Add(of + " x " + i + " = " + ans.ToString());
}
}
else
{
MessageBox.Show("Please enter a valid value");
}
}
This is a multiplication table generator. I have noticed that adding too many rows for listboxes made the program hang. Someone told me that I can use data grid view to overcome that problem. However,since I am a beginner, I need a little help to do that. I have searched internet but they are all codes about how to add SQL data to data grid view.
Any help will be appreciated