grdCustomer.DataSource = customerList;
void CreatingGrid(List<Company> CmpnyList) { dtgCompany.DataSource = dtCompany; dtCompany.Columns.Add("COMPANY ID"); dtCompany.Columns.Add("COMPANY CODE"); dtCompany.Columns.Add("COMPANY NAME"); dtCompany.Columns.Add("COMPANY ADDRESS"); dtCompany.Columns.Add("COMPANY PHONE"); //dtCompany.Columns.Add("Edit"); foreach (Company company in CmpnyList) { dtCompany = (DataTable)dtgCompany.DataSource; dtCompany.Rows.Add(dtCompany.NewRow()); dtCompany.Rows[dtCompany.Rows.Count - 1][0] = company._com_id.ToString(); dtCompany.Rows[dtCompany.Rows.Count - 1][1] = company.com_code.ToString(); dtCompany.Rows[dtCompany.Rows.Count - 1][2] = company.com_name.ToString(); dtCompany.Rows[dtCompany.Rows.Count - 1][3] = company.com_address.ToString(); dtCompany.Rows[dtCompany.Rows.Count - 1][4] = company.com_PhoneNo.ToString(); } }
grdCustomer. .Rows.Add() ; int rowIndex = grdCustomer.RowCount -1; DataGridViewRow newCustomerRow = grdCustomer.RowIndex[rowIndex]; newCustomerRow .Cell[“NAME”] = “JOHN”; newCustomerRow .Cell[“ADDRESS”] = “COLOMBO”; newCustomerRow .Cell[“AGE”] = 30; newCustomerRow .Cell[“EMAIL”] = “JOHN@YAHOO.COM”;
private void dtgCompany_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) { int rowNumber = e.RowIndex; if (!DBNull.Value.Equals(dtgCompany["COMPANY ID", rowNumber].Value)) { int grdRowRow = Convert.ToInt32(dtgCompany["COMPANY ID", rowNumber].Value); Company company_O = CompanyDAO.GetCompanyById(grdRowRow); this.bingObjectToControls(company_O); loc_frm.Show(); } } }
DataRow selectedRow = grdCusomer.FindByau_id(key); selectedRow.Delete();
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.