예제 #1
0
파일: Main.cs 프로젝트: chusiping/fasta
        //******************  添加智能提示的列表  ******************************
        public void Suggest()
        {
            AutoCompleteStringCollection acsc = new AutoCompleteStringCollection();
            ComboBoxItem cbi1 = new ComboBoxItem();
            string s = "";
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(AppSetting.xmlPath);
            }
            catch
            {
                if (System.IO.File.Exists(AppSetting.xmlPath))
                {
                    MessageBox.Show("消息内容", "读取文件" + AppSetting.xmlPath + "错误!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    DoXml.CreateExec();
                }

            }

            XmlNodeReader reader = new XmlNodeReader(doc);
            // 读取XML文件中的数据,并显示出来
            while (reader.Read())
            {
                //判断当前读取得节点类型
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        s = reader.Name;
                        if (s.Equals(AppSetting.keyWord))
                        {

                            cbi1.Text = reader.GetAttribute(0);
                            cbi1.Value = reader.GetAttribute(1);

                            acsc.Add(cbi1.Text);
                        }
                        break;

                }
            }
            this.comboBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
            this.comboBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;
            this.comboBox1.AutoCompleteCustomSource = acsc;
        }
예제 #2
0
파일: Form1.cs 프로젝트: chusiping/fasta
        //***************  修改的具体方法  ***********************
        void update()
        {
            ListViewItem p = new ListViewItem();
            p = listView1.SelectedItems[0];

            string ss1 = p.SubItems[0].Text;
            string ss2 = p.SubItems[1].Text;

            string s1 = textBox1.Text.Trim();
            string s2 = textBox2.Text.Trim();

            if (textBox2.Visible == false)
            {
                s2 ="";
                foreach (var item in this.Controls)
                {
                    if (item is ComboBox)
                    {
                        ComboBox cb = (ComboBox)item;
                        cb.Visible = false;
                        textBox2.Visible = true;
                        bool IsSeleNone = (cbmSeleIndex == -1);
                        for (int i = 0; i < cb.Items.Count; i++)
                        {
                            ComboBoxItem cbi = new ComboBoxItem();
                            cbi = (ComboBoxItem)cb.Items[i];
                            if (cbmSeleIndex == i)
                            {
                                cbi.Text = cb.Text;
                                if (cbi.Text == "") continue;
                            }
                            bool IsDele = (cbmSeleIndex != -1) && (i == cb.Items.Count - 1);
                            s2 += cbi.Text.Trim() + (i == cb.Items.Count-1 ? "" : ";");
                        }
                        if (IsSeleNone)
                        {
                            s2 += cb.Text.Trim() == "" ? "" : ";" + cb.Text;
                        }
                    }
                }
            }

            Xmlalias.Update(ss1, ss2, s1, s2);

            textBox1.Text = "";
            textBox2.Text = "";

            LoadListView(ListItemIndex);
            //SendMessage(listView1.Handle, 500, 200, 200);
            button1.Visible = true;
            button2.Visible = false;
            RefrushOwner();
        }
예제 #3
0
파일: Main.cs 프로젝트: chusiping/fasta
        public void ReadXml()
        {
            string s = "";
            XmlDocument doc = new XmlDocument();

            doc.Load(AppSetting.xmlPath);

            XmlNodeReader reader = new XmlNodeReader(doc);

            while (reader.Read())
            {

                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        s = reader.Name;
                        if (s.Equals(AppSetting.keyWord))
                        {

                            ComboBoxItem cbi1 = new ComboBoxItem();
                            cbi1.Text = reader.GetAttribute(0);
                            cbi1.Value = reader.GetAttribute(1);
                            comboBox1.Items.Add(cbi1);
                        }
                        break;

                }
            }
        }
예제 #4
0
파일: Form1.cs 프로젝트: chusiping/fasta
        //***************  修改按钮事件  ********************************************
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            ListViewItem p = new ListViewItem();
            p = listView1.Items[ListItemIndex];

            foreach (var item in this.Controls)
            {
                if (item is ComboBox)
                {
                    this.Controls.Remove((ComboBox)item);
                }
            }

            string[] arr = p.SubItems[1].Text.Split(';');
            if (arr.Length > 1)
            {
                ComboBox cb = new ComboBox();
                cb.Location = new Point(textBox2.Location.X, textBox2.Location.Y);
                cb.Width = 445;
                cb.DropDownWidth = 440;
                cb.DropDownClosed += new EventHandler(newComboxDropDown);

                for (int i = 0; i < arr.Length; i++)
                {
                    ComboBoxItem cm = new ComboBoxItem();
                    cm.Text = arr[i].ToString();
                    if (cm.Text.Trim() != "") cb.Items.Add(cm);
                }
                textBox2.Visible = false;
                cbmSeleIndex = -1;
                this.Controls.Add(cb);
            }
            else
            {
                textBox2.Visible = true;
                textBox2.Text = p.SubItems[1].Text;
            }

            button1.Visible = false;
            button2.Visible = true;
            textBox1.Text = p.SubItems[0].Text;

            RefrushOwner();
        }