private void LlenarMeses() { DataTable DT = new DataTable("MESES"); DT.Columns.AddRange( new DataColumn[] { new DataColumn("Id", typeof(int)), new DataColumn("SomePropertyOrColumnName", typeof(string)), }); string[] meses = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames; for (int i = 0; i < meses.Length; i++) { if (meses[i].Length > 0) { DT.Rows.Add(i + 1, meses[i].ToUpper()); } } listaMeses = new ListSelectionWrapper <DataRow>( DT.Rows, // "SomePropertyOrColumnName" will populate the Name // on ObjectSelectionWrapper. "SomePropertyOrColumnName", "(Seleccione meses)" ); cmbMeses.DataSource = listaMeses; cmbMeses.DisplayMemberSingleItem = "Name"; cmbMeses.DisplayMember = "Various"; cmbMeses.ValueMember = "Selected"; }
private void Form1_Load(object sender, EventArgs e) { PopulateManualCombo(); #region POPULATED USING A CUSTOM "IList" DATASOURCE _StatusList = new StatusList(); _StatusList.Add(new Status(1, "New")); _StatusList.Add(new Status(2, "Loaded")); _StatusList.Add(new Status(3, "Inserted")); Status UpdatedStatus = new Status(4, "Updated"); _StatusList.Add(UpdatedStatus); _StatusList.Add(new Status(5, "Deleted")); StatusSelections = new ListSelectionWrapper<Status>(_StatusList, "Name"); cmbIListDataSource.DataSource = StatusSelections; cmbIListDataSource.DisplayMemberSingleItem = "Name"; cmbIListDataSource.DisplayMember = "NameConcatenated"; cmbIListDataSource.ValueMember = "Selected"; cmbIListDataSource.CheckBoxItems[3].DataBindings.DefaultDataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged; cmbIListDataSource.DataBindings.DefaultDataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged; StatusSelections.FindObjectWithItem(UpdatedStatus).Selected = true; #endregion POPULATED USING A CUSTOM "IList" DATASOURCE #region POPULATED USING A DATATABLE DataTable DT = new DataTable("TEST TABLE FOR DEMO PURPOSES"); DT.Columns.AddRange( new DataColumn[] { new DataColumn("Id", typeof(int)), new DataColumn("SomePropertyOrColumnName", typeof(string)), new DataColumn("Description", typeof(string)), }); DT.Rows.Add(1, "AAAA", "AAAAA"); DT.Rows.Add(2, "BBBB", "BBBBB"); DT.Rows.Add(3, "CCCC", "CCCCC"); DT.Rows.Add(3, "DDDD", "DDDDD"); cmbDataTableDataSource.DataSource = new ListSelectionWrapper<DataRow>( DT.Rows, "SomePropertyOrColumnName" // "SomePropertyOrColumnName" will populate the Name on ObjectSelectionWrapper. ); cmbDataTableDataSource.DisplayMemberSingleItem = "Name"; cmbDataTableDataSource.DisplayMember = "NameConcatenated"; cmbDataTableDataSource.ValueMember = "Selected"; #endregion POPULATED USING A DATATABLE }
private void Form1_Load(object sender, EventArgs e) { PopulateManualCombo(); #region POPULATED USING A CUSTOM "IList" DATASOURCE _StatusList = new StatusList(); _StatusList.Add(new Status(1, "New")); _StatusList.Add(new Status(2, "Loaded")); _StatusList.Add(new Status(3, "Inserted")); Status UpdatedStatus = new Status(4, "Updated"); _StatusList.Add(UpdatedStatus); _StatusList.Add(new Status(5, "Deleted")); StatusSelections = new ListSelectionWrapper <Status>(_StatusList, "Name"); cmbIListDataSource.DataSource = StatusSelections; cmbIListDataSource.DisplayMemberSingleItem = "Name"; cmbIListDataSource.DisplayMember = "NameConcatenated"; cmbIListDataSource.ValueMember = "Selected"; cmbIListDataSource.CheckBoxItems[3].DataBindings.DefaultDataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged; cmbIListDataSource.DataBindings.DefaultDataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged; StatusSelections.FindObjectWithItem(UpdatedStatus).Selected = true; #endregion #region POPULATED USING A DATATABLE DataTable DT = new DataTable("TEST TABLE FOR DEMO PURPOSES"); DT.Columns.AddRange( new DataColumn[] { new DataColumn("Id", typeof(int)), new DataColumn("SomePropertyOrColumnName", typeof(string)), new DataColumn("Description", typeof(string)), }); DT.Rows.Add(1, "AAAA", "AAAAA"); DT.Rows.Add(2, "BBBB", "BBBBB"); DT.Rows.Add(3, "CCCC", "CCCCC"); DT.Rows.Add(3, "DDDD", "DDDDD"); cmbDataTableDataSource.DataSource = new ListSelectionWrapper <DataRow>( DT.Rows, "SomePropertyOrColumnName" // "SomePropertyOrColumnName" will populate the Name on ObjectSelectionWrapper. ); cmbDataTableDataSource.DisplayMemberSingleItem = "Name"; cmbDataTableDataSource.DisplayMember = "NameConcatenated"; cmbDataTableDataSource.ValueMember = "Selected"; #endregion }
private void LlenarOperativos() { DataTable dataTable = Conexion.GetTable("select Id_Oper as Id, Descripcion as SomePropertyOrColumnName from Operativo"); listaOperativos = new ListSelectionWrapper <DataRow>( dataTable.Rows, "SomePropertyOrColumnName", "(Seleccione operativos)" ); cmbOperativo.DataSource = listaOperativos; cmbOperativo.DisplayMemberSingleItem = "Name"; cmbOperativo.DisplayMember = "Various"; cmbOperativo.ValueMember = "Selected"; }
private List <string> getSelected(ListSelectionWrapper <DataRow> lista) { //Lista de operativos List <string> array = new List <string>(); foreach (ObjectSelectionWrapper <DataRow> objectSelectionWrapper in lista) { if (objectSelectionWrapper.Selected) { array.Add(objectSelectionWrapper.Item.Field <Object>("Id").ToString()); } } return(array); }
private void LlenarEspecialidades() { DataTable dataTable = Conexion.GetTable("select Id_Consultorio as Id, Descripcion as SomePropertyOrColumnName from Consultorios where Estado = 1"); listaEspecialidades = new ListSelectionWrapper <DataRow>( dataTable.Rows, "SomePropertyOrColumnName", "(Seleccione especialidades)" ); cmbEspecialidad.DataSource = listaEspecialidades; cmbEspecialidad.DisplayMemberSingleItem = "Name"; cmbEspecialidad.DisplayMember = "Various"; cmbEspecialidad.ValueMember = "Selected"; }
private void btnApplications_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbServer.Text)) { MessageBox.Show(@"Server name should not be empty"); } else { string connectionString = string.Format("SERVER={0};DATABASE=BizTalkMgmtDb;Integrated Security=SSPI", tbServer.Text); var catalog = new BtsCatalogExplorer { ConnectionString = connectionString }; List<Application> apps = catalog.Applications.Cast<Application>().ToList(); var appSelections = new ListSelectionWrapper<Application>(apps, "Name"); ddlApplications.DataSource = appSelections; ddlApplications.DisplayMemberSingleItem = "Name"; ddlApplications.DisplayMember = "NameConcatenated"; ddlApplications.ValueMember = "Selected"; } }
/// <summary> /// 帐户信息保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> //private void button1_Click(object sender, EventArgs e) //{ // string name = tb_name.Text.Trim(); // string pwd = tb_pwd.Text.Trim(); // int check = 0; // if (cb_Check.CheckState == CheckState.Checked) // check = 1; // UsersObject uo = new UsersObject(); // uo.h_UserName = name; // uo.h_yUserPwd = pwd; // uo.h_Status = 1; // Dictionary<string, List<string>> dic = LoadXmlConfig(); // List<string> li = dic.Keys.ToList(); // for (int i=0;i<li.Count;i++) // { // uo.Power += li[i] + ":;"; // } // uo.Power = uo.Power.Substring(0,uo.Power.Length-1); // User_BLL.AddUser(uo); // LoadSource(); // tb_name.Text = ""; // tb_pwd.Text = ""; //} /// <summary> /// 列表信息保存 /// </summary> public Dictionary <int, ListSelectionWrapper <Status> > SaveMessage() { Dictionary <int, ListSelectionWrapper <Status> > dic = new Dictionary <int, ListSelectionWrapper <Status> >(); Dictionary <string, List <string> > dicX = new Dictionary <string, List <string> >(); dicX = LoadXmlConfig(); ListSelectionWrapper <Status> StatusSelections; StatusList _StatusList = new StatusList(); List <string> list_basis = dicX["basis"].ToList(); for (int i = 0; i < list_basis.Count; i++) { Status sDD = new Status(i, list_basis[i].ToString()); _StatusList.Add(sDD); } StatusSelections = new ListSelectionWrapper <Status>(_StatusList, "Name"); dic.Add(0, StatusSelections); ListSelectionWrapper <Status> StatusSelections1; StatusList _StatusList1 = new StatusList(); List <string> list_plan = dicX["plan"].ToList(); for (int i = 0; i < list_plan.Count; i++) { Status sDD = new Status(i, list_plan[i].ToString()); _StatusList1.Add(sDD); } StatusSelections1 = new ListSelectionWrapper <Status>(_StatusList1, "Name"); dic.Add(1, StatusSelections1); ListSelectionWrapper <Status> StatusSelections2; StatusList _StatusList2 = new StatusList(); List <string> list_formula = dicX["formula"].ToList(); for (int i = 0; i < list_formula.Count; i++) { Status sDD = new Status(i, list_formula[i].ToString()); _StatusList2.Add(sDD); } StatusSelections2 = new ListSelectionWrapper <Status>(_StatusList2, "Name"); dic.Add(2, StatusSelections2); ListSelectionWrapper <Status> StatusSelections3; StatusList _StatusList3 = new StatusList(); List <string> list_table = dicX["table"].ToList(); for (int i = 0; i < list_table.Count; i++) { Status sDD = new Status(i, list_table[i].ToString()); _StatusList3.Add(sDD); } StatusSelections3 = new ListSelectionWrapper <Status>(_StatusList3, "Name"); dic.Add(3, StatusSelections3); ListSelectionWrapper <Status> StatusSelections4; StatusList _StatusList4 = new StatusList(); List <string> list_tool = dicX["tool"].ToList(); for (int i = 0; i < list_tool.Count; i++) { Status sDD = new Status(i, list_tool[i].ToString()); _StatusList4.Add(sDD); } StatusSelections4 = new ListSelectionWrapper <Status>(_StatusList4, "Name"); dic.Add(4, StatusSelections4); return(dic); }
private void btnAssemblies_Click(object sender, EventArgs e) { List<Application> applications = ddlApplications.CheckBoxItems.Where(x => x.Checked) .Select(x => ((ObjectSelectionWrapper<Application>)x.ComboBoxItem).Item) .ToList(); var assemblies = new List<BtsAssembly>(); foreach (Application application in applications) { assemblies.AddRange(application.Assemblies.Cast<BtsAssembly>().ToList()); } var assemblySelections = new ListSelectionWrapper<BtsAssembly>(assemblies, "Name"); ddlAssemblies.DataSource = assemblySelections; ddlAssemblies.DisplayMemberSingleItem = "Name"; ddlAssemblies.DisplayMember = "NameConcatenated"; ddlAssemblies.ValueMember = "Selected"; }