Ejemplo n.º 1
0
 public static void SetCheckedItems(CheckedListBoxControl listBox, StringCollection checkedNames)
 {
     for (int i = 0; i < listBox.Items.Count; ++i)
     {
         object item = listBox.Items[i];
         if ((checkedNames == null) || !checkedNames.Contains(item.ToString()))
         {
             if (listBox.GetItemChecked(i))
             {
                 listBox.SetItemChecked(i, false);
             }
         }
         else
         {
             if (!listBox.GetItemChecked(i))
             {
                 listBox.SetItemChecked(i, true);
             }
         }
     }
 }
Ejemplo n.º 2
0
        public static string GetCheckList(CheckedListBoxControl oCheckedListBoxControl)
        {
            string SelectValues = "";

            for (int i = 0; i < oCheckedListBoxControl.ItemCount; i++)
            {
                if (oCheckedListBoxControl.GetItemChecked(i))
                {
                    SelectValues += oCheckedListBoxControl.GetItemValue(i).ToString() + ",";
                }
            }
            return(SelectValues);
        }
        private void settingSecondaryItemListBoxControl_ItemCheck(object sender, DevExpress.XtraEditors.Controls.ItemCheckEventArgs e)
        {
            if (e.Index == 0)
            {
                return;
            }
            CheckedListBoxControl checkList = sender as CheckedListBoxControl;

            if (e.Index < checkList.ItemCount - 1 && e.State == CheckState.Unchecked)
            {
                if (checkList.GetItemChecked(checkList.ItemCount - 1))
                {
                    checkList.SetItemChecked(checkList.ItemCount - 1, false);
                }
            }
            else if (e.Index == checkList.ItemCount - 1)
            {
                if (e.State == CheckState.Checked)
                {
                    checkList.CheckAll();
                }
                else
                {
                    int checkCount = 0;
                    for (int index = 0; index < checkList.ItemCount - 1; index++)
                    {
                        if (checkList.GetItemChecked(index))
                        {
                            checkCount++;
                        }

                        if (checkCount == checkList.ItemCount - 1)
                        {
                            checkList.UnCheckAll();
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static void PersistSettingsByName(
            CheckedListBoxControl c,
            IPersistentPairStorage storage,
            string key)
        {
            var names = new List <string>();

            for (var i = 0; i < c.Items.Count; ++i)
            {
                if (c.GetItemChecked(i))
                {
                    names.Add(c.GetItem(i).ToString());
                }
            }

            PersistanceHelper.SaveValue(storage, key, string.Join(@"###{{{}}}###", names.ToArray()));
        }
		public static void PersistSettings(
			CheckedListBoxControl c,
			IPersistentPairStorage storage,
			string key )
		{
			var indexes = new List<string>();

			for ( var i = 0; i < c.Items.Count; ++i )
			{
				if ( c.GetItemChecked( i ) )
				{
					indexes.Add( i.ToString() );
				}
			}

			PersistanceHelper.SaveValue( storage, key, string.Join( @";", indexes.ToArray() ) );
		}
Ejemplo n.º 6
0
        public static void RestoreSettings(
            CheckedListBoxControl c,
            IPersistentPairStorage storage,
            string key)
        {
            var indexes = new List <string>();

            for (var i = 0; i < c.Items.Count; ++i)
            {
                if (c.GetItemChecked(i))
                {
                    indexes.Add(i.ToString());
                }
            }

            var def = string.Join(@";", indexes.ToArray());

            // --

            var s = PersistanceHelper.RestoreValue(
                storage,
                key,
                def) as string;

            if (string.IsNullOrEmpty(s))
            {
                for (var i = 0; i < c.Items.Count; ++i)
                {
                    c.SetItemChecked(i, false);
                }
            }
            else
            {
                var splitted = new List <string>(s.Split(';'));

                var ris = new List <int>();
                splitted.ForEach(x => ris.Add(int.Parse(x)));

                for (var i = 0; i < c.Items.Count; ++i)
                {
                    c.SetItemChecked(i, ris.Contains(i));
                }
            }
        }
		public static void RestoreSettings(
			CheckedListBoxControl c,
			IPersistentPairStorage storage,
			string key )
		{
			var indexes = new List<string>();

			for ( var i = 0; i < c.Items.Count; ++i )
			{
				if ( c.GetItemChecked( i ) )
				{
					indexes.Add( i.ToString() );
				}
			}

			var def = string.Join( @";", indexes.ToArray() );

			// --

			var s = PersistanceHelper.RestoreValue(
				storage,
				key,
				def ) as string;

			if ( string.IsNullOrEmpty( s ) )
			{
				for ( var i = 0; i < c.Items.Count; ++i )
				{
					c.SetItemChecked( i, false );
				}
			}
			else
			{
				var splitted = new List<string>( s.Split( ';' ) );

				var ris = new List<int>();
				splitted.ForEach( x => ris.Add( int.Parse( x ) ) );

				for ( var i = 0; i < c.Items.Count; ++i )
				{
					c.SetItemChecked( i, ris.Contains( i ) );
				}
			}
		}
Ejemplo n.º 8
0
        public static void RestoreSettingsByName(
            CheckedListBoxControl c,
            IPersistentPairStorage storage,
            string key)
        {
            var names = new List <string>();

            for (var i = 0; i < c.Items.Count; ++i)
            {
                if (c.GetItemChecked(i))
                {
                    names.Add(c.GetItem(i).ToString());
                }
            }

            var def = string.Join(@"###{{{}}}###", names.ToArray());

            // --

            var s = PersistanceHelper.RestoreValue(
                storage,
                key,
                def) as string;

            if (string.IsNullOrEmpty(s))
            {
                for (var i = 0; i < c.Items.Count; ++i)
                {
                    c.SetItemChecked(i, false);
                }
            }
            else
            {
                var splitted = new List <string>(s.Split(new[] { @"###{{{}}}###" }, StringSplitOptions.RemoveEmptyEntries));

                var ris = new List <string>(splitted);

                for (var i = 0; i < c.Items.Count; ++i)
                {
                    c.SetItemChecked(i, ris.Contains(c.GetItem(i).ToString()));
                }
            }
        }
Ejemplo n.º 9
0
        string GetCheckedListBoxChecked(CheckedListBoxControl chkControl)
        {
            string strCollected = string.Empty;

            for (int i = 0; i < chkControl.Items.Count; i++)
            {
                if (chkControl.GetItemChecked(i))
                {
                    if (strCollected == string.Empty)
                    {
                        strCollected = chkControl.GetItemValue(i).ToString();
                    }

                    else
                    {
                        strCollected = strCollected + "," + chkControl.GetItemValue(i);
                    }
                }
            }

            return(strCollected);
        }
		public static void RestoreSettingsByName(
			CheckedListBoxControl c,
			IPersistentPairStorage storage,
			string key )
		{
			var names = new List<string>();

			for ( var i = 0; i < c.Items.Count; ++i )
			{
				if ( c.GetItemChecked( i ) )
				{
					names.Add(c.GetItem(i).ToString());
				}
			}

			var def = string.Join(@"###{{{}}}###", names.ToArray());

			// --

			var s = PersistanceHelper.RestoreValue(
				storage,
				key,
				def ) as string;

			if ( string.IsNullOrEmpty( s ) )
			{
				for ( var i = 0; i < c.Items.Count; ++i )
				{
					c.SetItemChecked( i, false );
				}
			}
			else
			{
				var splitted = new List<string>(s.Split(new[] {@"###{{{}}}###"}, StringSplitOptions.RemoveEmptyEntries));

				var ris = new List<string>(splitted);

				for ( var i = 0; i < c.Items.Count; ++i )
				{
					c.SetItemChecked(i, ris.Contains(c.GetItem(i).ToString()));
				}
			}
		}