Beispiel #1
0
        public void ClearClearsTheList()
        {
            var list = new ListItemCollection <string>();

            var toAdd = new List <string>
            {
                "Foo",
                "Bar"
            };

            list.AddGroup("Bob", toAdd);
            list.Clear();

            list.Count.Should().Be(0);
        }
Beispiel #2
0
            /// <summary>
            /// 绑定控件的ListItem项
            /// </summary>
            /// <param name="LIC"></param>
            /// <param name="IsFistNull"></param>
            public void InitListItems(ListItemCollection LIC, bool IsFistNull)
            {
                if (LIC.Count > 0)
                {
                    LIC.Clear();
                }
                Hashtable ht = GetTextValue();

                foreach (DictionaryEntry de in ht)
                {
                    LIC.Add(new ListItem(de.Value.ToString(), de.Key.ToString()));
                }
                if (IsFistNull)
                {
                    LIC.Insert(0, "");
                }
            }
Beispiel #3
0
        /// <summary>
        /// Caricamento dati controllo destinatari
        /// </summary>
        /// <param name="items"></param>
        /// <param name="destinatari"></param>
        private void FetchItemsDestinatari(ListItemCollection items, Corrispondente[] destinatari)
        {
            items.Clear();

            if (destinatari == null || destinatari.Length == 0)
            {
                // Inserimento di un elemento vuoto, in caso non siano presenti destinatari
                items.Add(this.CreateEmptyElement());
            }
            else
            {
                foreach (Corrispondente destinatario in destinatari)
                {
                    items.Add(new ListItem(destinatario.descrizione, destinatario.systemId));
                }
            }
        }
Beispiel #4
0
        public void FillDatabaseVersions(int packageId, ListItemCollection items, List <string> versions)
        {
            if (versions == null)
            {
                return;
            }

            // load package context
            PackageContext cntx = PackagesHelper.GetCachedPackageContext(packageId);

            items.Clear();
            AddDatabaseVersion(cntx, ResourceGroups.MsSql2000, items, versions);
            AddDatabaseVersion(cntx, ResourceGroups.MsSql2005, items, versions);
            AddDatabaseVersion(cntx, ResourceGroups.MsSql2008, items, versions);
            AddDatabaseVersion(cntx, ResourceGroups.MySql4, items, versions);
            AddDatabaseVersion(cntx, ResourceGroups.MySql5, items, versions);
        }
Beispiel #5
0
	public void buildListBox(ListItemCollection Items,string sSQL, string sId, string sTitle, string CustomInitialDisplayValue,string CustomInitialSubmitValue)
	{	
		Items.Clear();
		OleDbCommand command = new OleDbCommand(sSQL, Connection);
		OleDbDataReader reader = command.ExecuteReader();
	
		if(CustomInitialDisplayValue!=null) Items.Add(new ListItem(CustomInitialDisplayValue,CustomInitialSubmitValue));

		while(reader.Read()) {	
			if(sId==""&&sTitle=="")	{
				Items.Add(new ListItem(reader[1].ToString(),reader[0].ToString()));
			}else{
				Items.Add(new ListItem(reader[sTitle].ToString(),reader[sId].ToString()));
			}
		}
		reader.Close();
	}
Beispiel #6
0
        public static void PopulateListItemCollectionFromStringEnumerable(IEnumerable <string> keys, ListItemCollection lic)
        {
            List <string> ls = new List <string>();   // ThAW 2009/09/11 : Can we pass the "keys" parameter directly to the constructor?

            foreach (string strKey in keys)
            {
                ls.Add(strKey);
            }

            ls.Sort();
            lic.Clear();

            foreach (string s in ls)
            {
                lic.Add(s);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Caricamento tipologie atto
        /// </summary>
        /// <param name="items"></param>
        private void FillItemsTipologiaAtto(ListItemCollection items)
        {
            TipologiaAtto[] tipologie = DocumentManager.getListaTipologiaAtto(this.Page);

            items.Clear();

            if (tipologie.Length == 0)
            {
                items.Add(this.CreateEmptyElement());
            }
            else
            {
                foreach (TipologiaAtto tipologia in tipologie)
                {
                    items.Add(new ListItem(tipologia.descrizione, tipologia.systemId));
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// 将一个DataTable的数据,绑定到一个List控件,比如下拉菜单
        /// </summary>
        /// <param name="targetControl">List控件的Items属性对象</param>
        /// <param name="dataSource">数据源DataTale</param>
        /// <param name="valueColumnName">List控件Value对应的DataTable列名</param>
        /// <param name="textColumnName">List控件Text对应的DataTable列名</param>
        /// <param name="topText">List控件第一行显示的文字,如果是null,则没有第一行</param>
        protected void DataBind(ListItemCollection targetControl, DataTable dataSource, string valueColumnName, string textColumnName, string topText)
        {
            targetControl.Clear();
            if (null == dataSource)
            {
                throw new NullReferenceException(string.Format("无法绑定控件{0},因为数据源是null"));
            }

            if (null != topText)
            {
                targetControl.Add(new ListItem(topText, "0"));
            }

            foreach (DataRow dr in dataSource.Rows)
            {
                targetControl.Add(new ListItem(dr[textColumnName].ToString(), dr[valueColumnName].ToString()));
            }
        }
Beispiel #9
0
    public void clearAllHistory(ListItemCollection uiCheckBox, SortedList <string, ArrayList> regimeDict, int currentYear)
    {
        ArrayList delKeyList = new ArrayList();

        foreach (KeyValuePair <string, ArrayList> dictEntry in regimeDict)
        {
            if (Convert.ToInt16(dictEntry.Key.Substring(7, 4)) < currentYear)
            {
                delKeyList.Add(dictEntry.Key);
            }
        }

        foreach (string delKey in delKeyList)
        {
            regimeDict.Remove(delKey);
        }

        uiCheckBox.Clear();
    }
Beispiel #10
0
    private void ListStrategy()
    {
        ListItemCollection list = ListBoxStrategy.Items;

        list.Clear();

        IList strategyList = TheAdminServer.StrategyManager.StrategyList;

        for (int i = 0; i < strategyList.Count; i++)
        {
            Strategy strategy = strategyList[i] as Strategy;
            string   itemText = strategy.ToString();
            if (!strategy.Enabled)
            {
                itemText += " [" + StringDef.Disable + "]";
            }
            list.Add(new ListItem(itemText, strategy.SecurityObject.Id.ToString()));
        }
    }
Beispiel #11
0
        // <snippet2>
        // Create the markup to display the control on the design surface.
        public override string GetDesignTimeHtml()
        {
            string designTimeMarkup = null;

            // Create variables to access the control
            // item collection and back color.
            ListItemCollection items = simpleRadioButtonList.Items;
            Color oldBackColor       = simpleRadioButtonList.BackColor;

            // Check the property values and render the markup
            // on the design surface accordingly.
            try
            {
                if (oldBackColor == Color.Empty)
                {
                    simpleRadioButtonList.BackColor = Color.Gainsboro;
                }

                if (changedDataSource)
                {
                    items.Add("Updated to a new data source: " +
                              DataSource + ".");
                }

                // Call the base method to generate the markup.
                designTimeMarkup = base.GetDesignTimeHtml();
            }
            catch (Exception ex)
            {
                // Catch any exceptions that occur.
                designTimeMarkup = GetErrorDesignTimeHtml(ex);
            }
            finally
            {
                // Set the properties back to their original state.
                simpleRadioButtonList.BackColor = oldBackColor;
                items.Clear();
            }

            return(designTimeMarkup);
        } // GetDesignTimeHtml
Beispiel #12
0
        public void Methods()
        {
            ListItemCollection c;
            ListItem           i;
            ListItem           i2;

            c = new ListItemCollection();
            Assert.AreEqual(0, c.Count, "T1");

            i = new ListItem("Item 1", "10");
            c.Add(i);
            Assert.AreEqual(1, c.Count, "T2");

            i = new ListItem("This is item 2", "20");
            c.Add(i);
            Assert.AreEqual(2, c.Count, "T3");

            Assert.AreEqual(null, c.FindByText(" is "), "T4");
            Assert.AreEqual(i.Text, c.FindByText("This is item 2").Text, "T5");
            Assert.AreSame(i, c.FindByText("This is item 2"), "T6");
            Assert.AreEqual(1, c.IndexOf(c.FindByText("This is item 2")), "T7");
            Assert.AreEqual(1, c.IndexOf(c.FindByValue("20")), "T8");

            i = new ListItem("Item 3", "30");
            Assert.IsFalse(c.Contains(i), "T9");
            c.Add(i);
            Assert.IsTrue(c.Contains(i), "T10");

            i  = new ListItem("Forth", "40");
            i2 = new ListItem("Fifth", "50");
            c.AddRange(new ListItem[] { i, i2 });
            Assert.AreEqual(5, c.Count, "T11");

            c.RemoveAt(1);
            Assert.AreEqual(4, c.Count, "T12");
            Assert.AreEqual(null, c.FindByText("This is item 2"), "T13");

            c.Clear();
            Assert.AreEqual(0, c.Count, "T13");
        }
        /// <summary>
        /// Loads the list items.
        /// </summary>
        /// <param name="list">The list.</param>
        /// <param name="rdr">The RDR.</param>
        /// <param name="textField">The text field.</param>
        /// <param name="valField">The val field.</param>
        /// <param name="selectedValue">The selected value.</param>
        /// <param name="closeReader">if set to <c>true</c> [close reader].</param>
        public static void LoadListItems(ListItemCollection list, IDataReader rdr, string textField, string valField, string selectedValue, bool closeReader)
        {
            list.Clear();

            if (closeReader)
            {
                using (rdr)
                {
                    while (rdr.Read())
                    {
                        string sText = rdr[textField].ToString();
                        string sVal  = rdr[valField].ToString();

                        ListItem l = new ListItem(sText, sVal);
                        if (!String.IsNullOrEmpty(selectedValue))
                        {
                            l.Selected = IsMatch(selectedValue, sVal);
                        }
                        list.Add(l);
                    }
                    rdr.Close();
                }
            }
            else
            {
                while (rdr.Read())
                {
                    string sText = rdr[textField].ToString();
                    string sVal  = rdr[valField].ToString();

                    ListItem l = new ListItem(sText, sVal);
                    if (!String.IsNullOrEmpty(selectedValue))
                    {
                        l.Selected = IsMatch(selectedValue, sVal);
                    }
                    list.Add(l);
                }
            }
        }
    void ListScheduledTask()
    {
        ListItemCollection list = ListBoxScheduledTask.Items;

        list.Clear();

        IList scheduledTaskList = TheAdminServer.ScheduledTaskManager.ScheduledTaskList;

        for (int i = 0; i < scheduledTaskList.Count; i++)
        {
            ScheduledTaskUnit unit     = scheduledTaskList[i] as ScheduledTaskUnit;
            string            itemText = unit.Task.ToString();
            if (!unit.Task.Enabled)
            {
                itemText += " [" + StringDef.Disable + "]";
            }
            ListItem item = new ListItem(itemText, unit.Task.SecurityObject.Id.ToString());
            //string color = unit.Task.Enabled ? "color:Green;" : "color:Red;";
            //item.Attributes.Add("style", color);
            list.Add(item);
        }

        ShowScheduledTaskCount();
    }
        public void ClearClearsTheList()
        {
            var list = new ListItemCollection<string>();

            var toAdd = new List<string>
            {
                "Foo",
                "Bar"
            };

            list.AddGroup("Bob", toAdd);
            list.Clear();

            list.Count.Should().Be(0);
        }
Beispiel #16
0
	public void buildListBox(ListItemCollection Items,string[] values, string CustomInitialDisplayValue,string CustomInitialSubmitValue)
	{	
		Items.Clear();
		if(CustomInitialDisplayValue!=null) Items.Add(new ListItem(CustomInitialDisplayValue,CustomInitialSubmitValue));
		for(int i=0;i<values.Length;i+=2)Items.Add(new ListItem(values[i+1],values[i]));
	}
Beispiel #17
0
        protected override void OnDataBinding(EventArgs e)
        {
            base.OnDataBinding(e);

            /* Make sure Items has been initialised */
            ListItemCollection listitems = Items;

            listitems.Clear();

            IEnumerable list;

#if NET_2_0
            list = GetData();
#else
            list = DataSourceResolver.ResolveDataSource(DataSource, DataMember);
#endif

            if (list == null)
            {
                return;
            }

            foreach (object container in list)
            {
                string text  = null;
                string value = null;

                if (DataTextField == String.Empty &&
                    DataValueField == String.Empty)
                {
                    text  = container.ToString();
                    value = text;
                }
                else
                {
                    if (DataTextField != String.Empty)
                    {
                        text = DataBinder.Eval(container, DataTextField).ToString();
                    }

                    if (DataValueField != String.Empty)
                    {
                        value = DataBinder.Eval(container, DataValueField).ToString();
                    }
                    else
                    {
                        value = text;
                    }

                    if (text == null &&
                        value != null)
                    {
                        text = value;
                    }
                }

                if (text == null)
                {
                    text = String.Empty;
                }
                if (value == null)
                {
                    value = String.Empty;
                }

                ListItem item = new ListItem(text, value);
                listitems.Add(item);
            }
#if NET_2_0
            RequiresDataBinding = false;
            IsDataBound         = true;
#endif
        }
        private void DownList()
        {
            try
            {
                ListItemCollection items = new DCSoft.Writer.Data.ListItemCollection();
                items.AddByTextValue("男", "男");
                items.AddByTextValue("女", "女");
                items.AddByTextValue("其他", "其他");
                myEditControl.AddBufferedListItems("sexlist", items, true);

                //items = new ListItemCollection();
                //items.Clear();
                //if (CurPatexam.dep == "XRAY")
                //{
                //    items.AddByTextValue("XRAY检查报告单", "XRAY");
                //}
                //else if (CurPatexam.dep == "CT")
                //{
                //    items.AddByTextValue("CT检查报告单", "CT");
                //}
                //else if (CurPatexam.dep == "MRI")
                //{
                //    items.AddByTextValue("MRI检查报告单", "MRI");
                //}
                //else if (CurPatexam.dep == "DSA")
                //{
                //    items.AddByTextValue("DSA检查报告单", "DSA");
                //}
                //myEditControl.AddBufferedListItems("ReportTypeList", items, true);

                DataSet ds = new DataSet();
                ds = Userinfo_Class.GetUserByDept(Share_Class.User.userflag);
                items = new ListItemCollection();
                items.Clear();
                //radio_doctor_ComboBoxEdit.Properties.Items.Clear();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    //radio_doctor_ComboBoxEdit.Properties.Items.Add(ds.Tables[0].Rows[i]["user_id"].ToString().Trim());
                    items.AddByTextValue(ds.Tables[0].Rows[i]["user_id"].ToString().Trim(), ds.Tables[0].Rows[i]["user_id"].ToString().Trim());
                }
                myEditControl.AddBufferedListItems("radio_doctorlist", items, true);
                myEditControl.AddBufferedListItems("reportdoclist", items, true);
                myEditControl.AddBufferedListItems("advancedoclist", items, true);


                ds = setup_noSort_Dmb_Class.GetAll("sqdep");
                items = new ListItemCollection();
                items.Clear();
                //sqdep_ComboBoxEdit.Properties.Items.Clear();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    items.AddByTextValue(ds.Tables[0].Rows[i]["sqdep"].ToString().Trim(), ds.Tables[0].Rows[i]["sqdep"].ToString().Trim());
                    // sqdep_ComboBoxEdit.Properties.Items.Add(ds.Tables[0].Rows[i]["sqdep"].ToString());
                }
                myEditControl.AddBufferedListItems("sqdeplist", items, true);

                //'ds = setup_noSort_Dmb_Class.GetAll("checkpos")
                //'items = new DCSoft.Writer.Data.ListItemCollection()
                //'items.Clear()
                //'For i = 0 To ds.Tables[0].Rows.Count - 1
                //'    items.AddByTextValue(ds.Tables[0].Rows[i]["checkpos"].ToString().Trim(), ds.Tables[0].Rows[i]["checkpos"].ToString().Trim())
                //'Next
                //'myEditControl.AddBufferedListItems("checkposlist", items, true);

                ds = setup_noSort_Dmb_Class.GetAll("ward");
                items = new ListItemCollection();
                items.Clear();
                //wardno_ComboBoxEdit.Properties.Items.Clear();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    items.AddByTextValue(ds.Tables[0].Rows[i]["ward"].ToString().Trim(), ds.Tables[0].Rows[i]["ward"].ToString().Trim());
                    //wardno_ComboBoxEdit.Properties.Items.Add(ds.Tables[0].Rows[i]["ward"].ToString());
                }
                myEditControl.AddBufferedListItems("wardlist", items, true);

                ds = setup_noSort_Dmb_Class.GetAll("doctor");
                items = new ListItemCollection();
                items.Clear();
                //doctor_ComboBoxEdit.Properties.Items.Clear();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    items.AddByTextValue(ds.Tables[0].Rows[i]["doctor"].ToString().Trim(), ds.Tables[0].Rows[i]["doctor"].ToString().Trim());
                    //doctor_ComboBoxEdit.Properties.Items.Add(ds.Tables[0].Rows[i]["doctor"].ToString());
                }
                myEditControl.AddBufferedListItems("doctorlist", items, true);
                ds = setup_noSort_Dmb_Class.GetAll("machinetype");
                items = new ListItemCollection();
                items.Clear();
                //machinetype_ComboBoxEdit.Properties.Items.Clear();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    items.AddByTextValue(ds.Tables[0].Rows[i]["machinetype"].ToString().Trim(), ds.Tables[0].Rows[i]["machinetype"].ToString().Trim());
                    //machinetype_ComboBoxEdit.Properties.Items.Add(ds.Tables[0].Rows[i]["machinetype"].ToString());
                }
                myEditControl.AddBufferedListItems("machinetypelist", items, true);

                ds = setup_registerpart_Dmb_Class.Getmodality();
                items = new ListItemCollection();
                items.Clear();
                //modality_ComboBoxEdit.Properties.Items.Clear();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    items.AddByTextValue(ds.Tables[0].Rows[i]["modality"].ToString().Trim(), ds.Tables[0].Rows[i]["modality"].ToString().Trim());
                    //modality_ComboBoxEdit.Properties.Items.Add(ds.Tables[0].Rows[i]["modality"].ToString());
                }
                myEditControl.AddBufferedListItems("modalitylist", items, true);

                ds = setup_noSort_Dmb_Class.GetAll("imagemethod");
                items = new ListItemCollection();
                items.Clear();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    items.AddByTextValue(ds.Tables[0].Rows[i]["imagemethod"].ToString().Trim(), ds.Tables[0].Rows[i]["imagemethod"].ToString().Trim());
                    //imagemethod_ComboBoxEdit.Properties.Items.Add(ds.Tables[0].Rows[i]["imagemethod"].ToString());
                }
                myEditControl.AddBufferedListItems("imagemethodlist", items, true);
                myEditControl.ExcludeKeywords = "白痴";
                //   '报告类型列表框填充
                ds = setup_noSort_Dmb_Class.GetAll("reportdisease_Dmb");
                items = new ListItemCollection();
                items.Clear();
                //  reportdisease_CheckedListBoxControl.Items.Clear();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    items.AddByTextValue(ds.Tables[0].Rows[i]["reportdisease"].ToString().Trim(), ds.Tables[0].Rows[i]["reportdisease"].ToString().Trim());
                    // reportdisease_CheckedListBoxControl.Items.Add(ds.Tables[0].Rows[i]["reportdisease"].ToString(), CheckState.Unchecked);

                }
                myEditControl.AddBufferedListItems("reportdiseaselist", items, true);

                // '结果归类列表框填充
                ds = setup_noSort_Dmb_Class.GetAll("diseasetype");
                items = new ListItemCollection();
                items.Clear();
                //   '填充数据库中调出的项
                // diseasetype_CheckedListBoxControl.Items.Clear();
                //Picdiseasetype_ComboBoxEdit.Properties.Items.Clear();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    items.AddByTextValue(ds.Tables[0].Rows[i]["diseasetype"].ToString().Trim(), ds.Tables[0].Rows[i]["diseasetype"].ToString().Trim());

                    //   diseasetype_CheckedListBoxControl.Items.Add(ds.Tables[0].Rows[i]["diseasetype"].ToString(), CheckState.Unchecked);
                    //Picdiseasetype_ComboBoxEdit.Properties.Items.Add(ds.Tables[0].Rows[i]["diseasetype"].ToString());
                }
                myEditControl.AddBufferedListItems("diseasetypelist", items, true);

                // '结果归类列表框填充
                ds = Setup_Dict.setup_item_dic_dmb_Class.GetITEM(CurPatexam.dep, "", "扫描方式", "");
                //ds = setup_noSort_Dmb_Class.GetAll("diseasetype");
                items = new ListItemCollection();
                items.Clear();
                //   '填充数据库中调出的项
                // diseasetype_CheckedListBoxControl.Items.Clear();
                //Picdiseasetype_ComboBoxEdit.Properties.Items.Clear();
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    items.AddByTextValue(ds.Tables[0].Rows[i]["item"].ToString().Trim(), ds.Tables[0].Rows[i]["item"].ToString().Trim());

                    //   diseasetype_CheckedListBoxControl.Items.Add(ds.Tables[0].Rows[i]["diseasetype"].ToString(), CheckState.Unchecked);
                    //Picdiseasetype_ComboBoxEdit.Properties.Items.Add(ds.Tables[0].Rows[i]["diseasetype"].ToString());
                }
                myEditControl.AddBufferedListItems("checktypelist", items, true);
            }
            catch (Exception ex)
            {
                flog_Class.WriteFlog(ex.Message);
            }
        }