private void inicio() { try { txtID.Text = string.Empty; txtNome.Text = string.Empty; cCliente cli = new cCliente(); using (DataSet ds = cli.preenche_lista_cliente()) { using (DataTable dt = ds.Tables["Clientes"]) { #region listview lvClientes.Clear(); lvClientes.View = View.Details; lvClientes.LabelEdit = true; lvClientes.AllowColumnReorder = true; lvClientes.CheckBoxes = false; lvClientes.FullRowSelect = true; lvClientes.GridLines = true; // lvClientes.Sorting = SortOrder.Ascending; lvClientes.Columns.Add("ID", 50); lvClientes.Columns.Add("Nome", 320, HorizontalAlignment.Left); //lvClientes.Columns.Add("Cadastro por", 120, HorizontalAlignment.Left); //lvClientes.Columns.Add("Data Cadastro", 120, HorizontalAlignment.Left); for (int i = 0; i < dt.Rows.Count; i++) { DataRow drw = dt.Rows[i]; ListViewItem lvi = new ListViewItem(drw["ID_CLIENTE"].ToString()); lvi.SubItems.Add(drw["CLIENTE"].ToString().ToUpper()); //lvi.SubItems.Add(drw["USERCAD"].ToString()); //lvi.SubItems.Add(drw["DTCAD"].ToString().Substring(0, 10)); lvClientes.Items.Add(lvi); } lblTotalReg.Text = string.Concat("Total de ", lvClientes.Items.Count, " registro(s)"); #endregion } } if (lvClientes.Items.Count == 0) { mnuOculto.Enabled = false; } else { mnuOculto.Enabled = true; } if (lvClientes.Items.Count > 0) { lvClientes.Items[0].Selected = true; lvClientes_Click(null, null); } } catch (Exception ex) { throw ex; } }