ODD One out Quiz

Sunday, 16 February 2014



Program to store Elements in 2-D Array Using Window Form and print elements in tabular form or matrix form..

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 Two_D_Array
{
public partial class Form1 : Form
{
int row, col;
int i=0, j=0;
int[,] a;
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{

row = Convert.ToInt32(textBox1.Text);
col = Convert.ToInt32(textBox2.Text);
a= new int[row,col];
}

private void textBox2_TextChanged(object sender, EventArgs e)
{

}

private void button2_Click(object sender, EventArgs e)
{
//i=0;j=0;
if(i<row)
{
if(j<col)
{
a[i, j] = Convert.ToInt32(textBox3.Text);
textBox3.Text = "";
listBox1.Items.Add(a[i, j]);
textBox4.Text += a[i, j].ToString() + "\t";
j++;

}
else
{
i++;
j = 0;
textBox4.Text += "\n";
}
}
}

}
}




No comments:

Post a Comment