InitializeComponent();
// Set the view to show details.
lvwResult.View = View.Details;
// Allow the user to edit item text.
lvwResult.LabelEdit = true;
// Allow the user to rearrange columns.
lvwResult.AllowColumnReorder = true;
// Select the item and subitems when selection is made.
lvwResult.FullRowSelect = true;
// Display grid lines.
lvwResult.GridLines = true;
// Sort the items in the list in ascending order.
lvwResult.Sorting = SortOrder.Ascending;
private void Form_Load()
{
lvwResult.Columns.Clear();
lvwResult.Items.Clear();
lvwResult.View = View.Details;
lvwResult.LabelEdit = true;
lvwResult.Columns.Add("Company ID", 100, HorizontalAlignment.Center);
lvwResult.Columns.Add("Company Name", 150, HorizontalAlignment.Center);
lvwResult.Columns.Add("Company Website", 150, HorizontalAlignment.Center);
lvwResult.Columns.Add("Company Email", 150, HorizontalAlignment.Center);
con.Open();
lvwResult.Items.Clear();
lvwResult.Refresh();
string OleDb = "select * from Company";
OleDbCommand cmd = new OleDbCommand(OleDb, con);
OleDbDataAdapter dap = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
dap.Fill(ds);
DataTable dt = ds.Tables[0];
for (int i = 0; i < dt.Rows.Count; i++)
{
DataRow dr = dt.Rows[i];
ListViewItem lvi = new ListViewItem(dr["companyID"].ToString());
lvi.SubItems.Add(dr["companyName"].ToString());
lvi.SubItems.Add(dr["companyWebsite"].ToString());
lvi.SubItems.Add(dr["companyEmail"].ToString());
lvwResult.Items.Add(lvi);
lvwResult.FullRowSelect = true;
}
con.Close();
}
private void lvwResult_SelectedIndexChanged(object sender, EventArgs e)
{
if (lvwResult.SelectedItems.Count > 0)
{
textBox1.Text = lvwResult.SelectedItems[0].Text;
}
ViewCompanyDetails objViewCompanyDetails = new ViewCompanyDetails(textBox1.Text);
objViewCompanyDetails.MdiParent = this.MdiParent;
objViewCompanyDetails.Dock = DockStyle.Fill;
objViewCompanyDetails.Show();
objViewCompanyDetails.Focus();
this.Hide();
}
// Set the view to show details.
lvwResult.View = View.Details;
// Allow the user to edit item text.
lvwResult.LabelEdit = true;
// Allow the user to rearrange columns.
lvwResult.AllowColumnReorder = true;
// Select the item and subitems when selection is made.
lvwResult.FullRowSelect = true;
// Display grid lines.
lvwResult.GridLines = true;
// Sort the items in the list in ascending order.
lvwResult.Sorting = SortOrder.Ascending;
private void Form_Load()
{
lvwResult.Columns.Clear();
lvwResult.Items.Clear();
lvwResult.View = View.Details;
lvwResult.LabelEdit = true;
lvwResult.Columns.Add("Company ID", 100, HorizontalAlignment.Center);
lvwResult.Columns.Add("Company Name", 150, HorizontalAlignment.Center);
lvwResult.Columns.Add("Company Website", 150, HorizontalAlignment.Center);
lvwResult.Columns.Add("Company Email", 150, HorizontalAlignment.Center);
con.Open();
lvwResult.Items.Clear();
lvwResult.Refresh();
string OleDb = "select * from Company";
OleDbCommand cmd = new OleDbCommand(OleDb, con);
OleDbDataAdapter dap = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
dap.Fill(ds);
DataTable dt = ds.Tables[0];
for (int i = 0; i < dt.Rows.Count; i++)
{
DataRow dr = dt.Rows[i];
ListViewItem lvi = new ListViewItem(dr["companyID"].ToString());
lvi.SubItems.Add(dr["companyName"].ToString());
lvi.SubItems.Add(dr["companyWebsite"].ToString());
lvi.SubItems.Add(dr["companyEmail"].ToString());
lvwResult.Items.Add(lvi);
lvwResult.FullRowSelect = true;
}
con.Close();
}
private void lvwResult_SelectedIndexChanged(object sender, EventArgs e)
{
if (lvwResult.SelectedItems.Count > 0)
{
textBox1.Text = lvwResult.SelectedItems[0].Text;
}
ViewCompanyDetails objViewCompanyDetails = new ViewCompanyDetails(textBox1.Text);
objViewCompanyDetails.MdiParent = this.MdiParent;
objViewCompanyDetails.Dock = DockStyle.Fill;
objViewCompanyDetails.Show();
objViewCompanyDetails.Focus();
this.Hide();
}
No comments:
Post a Comment