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");
		}
예제 #2
0
        public static void CreateHoursList(ListItemCollection ListItems, SortDirection direction)
        {
            int from = 0, to = 23, step = 1;
            if (direction == SortDirection.Descending)
            {
                from = 23; to = 0; step = -1;
            }

            if (Micajah.Common.Security.UserContext.Current.TimeFormat == 0) //AM/PM time format
            {
                for (int i = from; (direction == SortDirection.Ascending && i <= to) || (direction == SortDirection.Descending && i >= to); i += step)
                    if (i < 12)
                        ListItems.Add(new ListItem(i.ToString() + "am", i.ToString()));
                    else if (i > 12)
                        ListItems.Add(new ListItem((i - 12).ToString() + "pm", i.ToString()));
                    else
                        ListItems.Add(new ListItem(i.ToString() + "noon", i.ToString()));

                ListItems.FindByValue("0").Text = "12am";
            }
            else
                for (int i = from; (direction == SortDirection.Ascending && i <= to) || (direction == SortDirection.Descending && i >= to); i += step) ListItems.Add(new ListItem(FormatTimePart(i), i.ToString()));
        }
예제 #3
0
        protected string ProjectWhereString()
        {
            StringBuilder ret = new StringBuilder();

            ListItemCollection items_ = new ListItemCollection();
            foreach (ListItem itm in DDLProject.Items)
            {
                items_.Add(itm);
            }

            items_.Remove(items_.FindByValue("0"));

            for (int i = 0; i < items_.Count; i++)
            {
                ret.Append(string.Format("'{0}'", items_[i].Value));

                if (i < items_.Count - 1)
                {
                    ret.Append(",");
                }
            }
            return ret.ToString();
        }
예제 #4
0
 /// <summary>
 /// Sets the selected.
 /// </summary>
 /// <param name="lstItems">The LST items.</param>
 /// <param name="selectedValue">The selected value.</param>
 public static void SetSelected(ListItemCollection lstItems, string selectedValue)
 {
     ListItem item = lstItems.FindByValue(selectedValue);
     if (item != null) item.Selected = true;
 }
예제 #5
0
        private void filtrarListaDasConsultas(ListItemCollection listItemCollection)
        {
            foreach (GridViewRow tt in GridView1.Rows)
            {
                tt.Visible = true;
            }
            foreach (GridViewRow tt in GridView1.Rows)
            {
                string foundText;
                try
                {
                    foundText = listItemCollection.FindByValue(tt.Cells[7].Text).Value;

                }
                catch (Exception e)
                {
                    tt.Visible = false;
                }

            }
        }