private void buttonModify_Click(object sender, EventArgs e) { ListViewItem lvi = getSelectedCompany(); if (lvi == null) { return; } string company, street1, street2, city, state, zip, phone, fax; getListViewParts(lvi, out company, out street1, out street2, out city, out state, out zip, out phone, out fax); FormCompanyNew fcn = new FormCompanyNew(company, street1, street2, city, state, zip, phone, fax); fcn.ShowDialog(this); if (fcn.IsConfirmed) { int index = this.listViewCompanies.SelectedIndices[0]; updateCompanyRow(fcn._CompanyName, fcn._Street1, fcn._Street2, fcn._City, fcn._State, fcn._Zip, fcn._Phone, fcn._Fax); buildListView(); this.listViewCompanies.Items[index].Selected = true; this.listViewCompanies.Select(); // ensure visable this.listViewCompanies.EnsureVisible(index); } }
private void buttonAdd_Click(object sender, EventArgs e) { FormCompanyNew fcn = new FormCompanyNew("", "", "", "", "", "", "", ""); fcn.ShowDialog(this); if (fcn.IsConfirmed) { insertRowCompany(fcn._CompanyName, fcn._Street1, fcn._Street2, fcn._City, fcn._State, fcn._Zip, fcn._Phone, fcn._Fax); buildListView(); } }