1.Create a windows Form Application using Visual C#.Windows form consists of DataGridView and “Add Items” Button.
2.When Add Item button is clicked, the Information dialog box will come up and let the
visitor key in the information as shown.
3.After the user has key in the information of the dialog box, the information will be
Display on the DataGridView as shown.
4.All the data to be stored in the text file. The information can be read back and displayed while the application open again.
additional information copied from comment below
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 Test
{
public partial class FrmDeclaration : Form
{
public FrmDeclaration()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, EventArgs e)
{
FrmDetails FrmDetails = new FrmDetails();
FrmDetails.DetailUpdated += new FrmDetails.DetailUpdateHandler(DetailForm_ButtonClicked);
FrmDetails.Show();
}
private void DetailForm_ButtonClicked(object sender, DetailUpdateEventArgs e)
{
dataGridView.ColumnCount = 8;
dataGridView.Columns[0].Name = "NAME";
dataGridView.Columns[1].Name = "NRIC";
dataGridView.Columns[2].Name = "DATE";
dataGridView.Columns[3].Name = "COMPANY";
dataGridView.Columns[4].Name = "TELEPHONE";
dataGridView.Columns[5].Name = "CONTACT PERSON";
dataGridView.Columns[6].Name = "PURPOSE";
dataGridView.Columns[7].Name = "ITEM";
}
}
}
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 Test
{
public partial class FrmDetails : Form
{
public delegate void DetailUpdateHandler(object sender, DetailUpdateEventArgs e);
public event DetailUpdateHandler DetailUpdated;
public FrmDetails()
{
InitializeComponent();
}
private void btnOK_Click(object sender, EventArgs e)
{
string sNewName = txtName.Text;
string sNewNRIC = txtNRIC.Text;
string sNewDate = txtDate.Text;
string sNewCompany = txtCompany.Text;
string sNewTel = txtTel.Text;
string sNewContact = txtContact.Text;
DetailUpdateEventArgs args = new DetailUpdateEventArgs(sNewName,
sNewNRIC, sNewDate, sNewCompany, sNewTel, sNewContact);
DetailUpdated(this, args);
this.Dispose();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Dispose();
}
}
public class DetailUpdateEventArgs : System.EventArgs
{
private string mNewName;
private string mNewNRIC;
private string mNewDate;
private string mNewCompany;
private string mNewTel;
private string mNewContact;
public DetailUpdateEventArgs(string sNewName, string sNewNRIC,
string sNewDate, string sNewCompany, string sNewTel,
string sNewContact)
{
this.mNewName = sNewName;
this.mNewNRIC = sNewNRIC;
this.mNewDate = sNewDate;
this.mNewCompany = sNewCompany;
this.mNewTel = sNewTel;
this.mNewContact = sNewContact;
}
public string Name
{
get
{
return mNewName;
}
}
public string NRIC
{
get
{
return mNewNRIC;
}
}
public string Date
{
get
{
return mNewDate;
}
}
public string Company
{
get
{
return mNewCompany;
}
}
public string Tel
{
get
{
return mNewTel;
}
}
public string Contact
{
get
{
return mNewContact;
}
}
}
}
that my codes.. i got no idea why its not working