private string Cadena(CheckedListBox clb) { StringBuilder stbCobranza = new StringBuilder(); foreach (DataRowView item in clb.CheckedItems) { if (item["Codigo"].ToString() != "0") { if (!clb.ToString().Equals(string.Empty)) { stbCobranza.Append(","); } stbCobranza.Append(item["Nombre"].ToString()); } } if (clb.CheckedItems.Count == 0) { foreach (DataRowView item in clb.Items) { if (item["Codigo"].ToString() != "0") { if (!clb.ToString().Equals(string.Empty)) { stbCobranza.Append(","); } stbCobranza.Append(item["Nombre"].ToString()); } } } return(stbCobranza.ToString()); }
public string GetCadena(CheckedListBox cb) { StringBuilder stb = new StringBuilder(); foreach (DataRowView item in cb.CheckedItems) { if (item["Codigo"].ToString() != "0") { if (!cb.ToString().Equals(string.Empty)) { stb.Append(","); } stb.Append(item["Codigo"].ToString()); } } if (cb.CheckedItems.Count == 0) { foreach (DataRowView item in cb.Items) { if (item["Codigo"].ToString() != "0") { if (!cb.ToString().Equals(string.Empty)) { stb.Append(","); } stb.Append(item["Codigo"].ToString()); } } } return(stb.ToString()); }
public List <string> GetCadena(CheckedListBox cb) { List <string> listReturn = new List <string>(); StringBuilder stb = new StringBuilder(); foreach (DataRowView item in cb.CheckedItems) { if (item["Codigo"].ToString() != "0") { if (!cb.ToString().Equals(string.Empty)) { stb.Append(","); } stb.Append(item["Codigo"].ToString()); listReturn.Add(item["Nombre"].ToString()); } } if (cb.CheckedItems.Count == 0) { foreach (DataRowView item in cb.Items) { if (item["Codigo"].ToString() != "0") { if (!cb.ToString().Equals(string.Empty)) { stb.Append(","); } stb.Append(item["Codigo"].ToString()); listReturn.Add(item["Nombre"].ToString()); } } } return(listReturn); }
private string Cadena(CheckedListBox clb) { StringBuilder stb = new StringBuilder(); foreach (DataRowView item in clb.CheckedItems) { if (item["Codigo"].ToString() != "0") { if (!clb.ToString().Equals(string.Empty)) { stb.Append(","); } stb.Append(item["Codigo"].ToString()); } } if (clb.CheckedItems.Count == 0) { stb.Clear(); stb.Append("Todo"); } if (clb.CheckedItems.Count == clb.Items.Count) { stb.Clear(); stb.Append("Todo"); } return(stb.ToString()); }
public static string getCadena(CheckedListBox clb, string separador, bool vacia, string columName) { StringBuilder stb = new StringBuilder(); foreach (DataRowView item in clb.CheckedItems) { if (item[columName].ToString() != "0") { if (!clb.ToString().Equals(string.Empty)) { stb.Append(","); } stb.Append(separador + item[columName] + separador); } } if (clb.CheckedItems.Count == 0) { foreach (DataRowView item in clb.Items) { if (item[columName].ToString() != "0") { if (!clb.ToString().Equals(string.Empty)) { stb.Append(","); } stb.Append(separador + item[columName] + separador); } } if (vacia) { return(string.Empty); } } return(stb.ToString().Trim(',')); }
public string GetCadena(CheckedListBox clb) { StringBuilder stb = new StringBuilder(); foreach (DataRowView item in clb.CheckedItems) { if (clb.CheckedItems.Count != 0) { if (item["Codigo"].ToString() != "0") { if (!clb.ToString().Equals(string.Empty)) { stb.Append("'" + item["Nombre"].ToString() + "',"); } } } } return(stb.ToString().Trim(',')); }
private void button1_Click(object sender, EventArgs e) { try { listaFiltros.Clear(); CheckedListBox clb = clbFiltro; StringBuilder stb = new StringBuilder(); foreach (DataRowView item in clb.CheckedItems) { if (item["Nombre"].ToString() != "0") { if (!clb.ToString().Equals(string.Empty)) { stb.Append(","); } stb.Append("'" + item["Nombre"].ToString() + "'"); listaFiltros.Add(item["Nombre"].ToString()); } } foreach (DataGridViewRow item in dgvPJ.Rows) { if (!item.IsNewRow) { if (this.dgvPJ.CurrentCell != null) { this.dgvPJ.CurrentCell = null; } if (!listaFiltros.Contains(item.Cells[(int)Columas.Estatus].Value.ToString())) { item.Visible = false; } else { item.Visible = true; } } } foreach (DataGridViewRow item in dgvTrZone.Rows) { if (!item.IsNewRow) { if (this.dgvTrZone.CurrentCell != null) { this.dgvTrZone.CurrentCell = null; } if (!listaFiltros.Contains(item.Cells[(int)Columas.Estatus].Value.ToString())) { item.Visible = false; } else { item.Visible = true; } } } }catch (Exception) { } }