zoukankan      html  css  js  c++  java
  • C#.NET ListBox.cs

         public void SetListBox(ListBox TargetBox, DataTable dt, int Col)
            {
                TargetBox.Items.Clear();
                foreach (DataRow dr in dt.Rows)
                {
                    TargetBox.Items.Add(dr[Col].ToString());
                }
            }

            public void MoveListBoxAll(ListBox SourceBox, ListBox TargetBox)
            {
                string tmpStr = "";
                for (int i = SourceBox.Items.Count; i > 0; i--)
                {
                    tmpStr = SourceBox.Items[i - 1].ToString();
                    TargetBox.Items.Add(tmpStr);
                    SourceBox.Items.Remove(tmpStr);
                }
            }

            public void MoveListBoxBySelected(ListBox SourceBox, ListBox TargetBox)
            {
                int i = SourceBox.SelectedItems.Count;
                if (i == 0)
                {
                    return;
                }
                string[] tmpStr = new string[i];
                int j = 0;
                foreach (string lbitem in SourceBox.SelectedItems)
                {
                    tmpStr[j] = lbitem;
                    j = j + 1;
                }

                foreach (string lbitem in tmpStr)
                {
                    TargetBox.Items.Add(lbitem);
                    SourceBox.Items.Remove(lbitem);
                }
            }

  • 相关阅读:
    怎么制作html5网站页面让它适应电脑和手机的尺寸
    js面向对象 下
    认识面向对象及代码示例
    Math 对象
    js事件驱动函数
    模拟js中注册表单验证
    敏感词过滤 简单 模仿
    模仿随机验证码-简单效果
    字符串方法(函数)
    js中字符串概念
  • 原文地址:https://www.cnblogs.com/cuishao1985/p/1343348.html
Copyright © 2011-2022 走看看