Example #1
0
        // 构造勾选事项字符串
        string GetValue()
        {
            List <NumberedString> results = new List <NumberedString>();
            string strResult = "";

            for (int i = 0; i < this.listView1.Items.Count; i++)
            {
                ListViewItem item = this.listView1.Items[i];
                if (item.Checked == false)
                {
                    continue;
                }

                ItemInfo iteminfo = null;
                if (item.Tag != null)
                {
                    iteminfo = (ItemInfo)item.Tag;
                }
                else
                {
                    iteminfo       = new ItemInfo();
                    iteminfo.Index = 99999;
                }

                NumberedString one = new NumberedString();
                one.Index = iteminfo.Index;
                if (this.ReturnFirstPart == false)
                {
                    one.Text = ListViewUtil.GetLineText(item);
                }
                else
                {
                    one.Text = ListViewUtil.GetItemText(item, 0);
                }
                results.Add(one);
            }

            // 排序
            results.Sort(new NumberdStringCompare());

            for (int i = 0; i < results.Count; i++)
            {
                if (String.IsNullOrEmpty(strResult) == false)
                {
                    strResult += ",";
                }
                strResult += results[i].Text;
            }

            return(strResult);
        }