コード例 #1
0
ファイル: frmLoadElement.cs プロジェクト: iamwsx05/hms
        private void AddElement()
        {
            BindingListView <EntityElementTemplate> source = clstElement.DataSource as BindingListView <EntityElementTemplate>;

            if (source != null)
            {
                BindingListView <EntityElementTemplate> tempSource = new BindingListView <EntityElementTemplate>();
                EntityElementTemplate objNew = new EntityElementTemplate();
                objNew.serno      = -1;
                objNew.colcontent = "    ";
                tempSource.Add(objNew);
                foreach (EntityElementTemplate objCurrent in source)
                {
                    tempSource.Add(objCurrent);
                }
                clstElement.DataSource = tempSource;
            }

            biAdd.Enabled         = false;
            biDel.Enabled         = false;
            biMultiChoose.Enabled = false;
            biEdit.Enabled        = false;

            txtNew      = new DevExpress.XtraEditors.TextEdit();
            txtNew.Name = "txtNew";
            int intCount  = clstElement.ItemCount;
            int intHeight = (intCount + 1) * clstElement.ItemHeight;

            txtNew.Location = new Point(0, 0);
            if (clstElement.Height <= intHeight)
            {
                txtNew.Width = clstElement.Width - 17;
            }
            else
            {
                txtNew.Width = clstElement.Width;
            }
            txtNew.Height   = clstElement.ItemHeight;
            txtNew.KeyDown += new KeyEventHandler(txtNew_KeyDown);
            txtNew.Leave   += new EventHandler(txtNew_Leave);


            clstElement.Controls.Add(txtNew);
            txtNew.BringToFront();
            txtNew.Focus();
        }
コード例 #2
0
ファイル: frmLoadElement.cs プロジェクト: iamwsx05/hms
        private void biElementEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (clstElement.SelectedItem == null)
            {
                return;
            }

            m_intFlags = 1;
            Rectangle rtg = clstElement.GetItemRectangle(clstElement.SelectedIndex);

            biAdd.Enabled         = false;
            biDel.Enabled         = false;
            biMultiChoose.Enabled = false;
            biEdit.Enabled        = false;
            txtNew      = new DevExpress.XtraEditors.TextEdit();
            txtNew.Name = "txtNew";
            int intCount  = clstElement.ItemCount;
            int intHeight = (intCount + 1) * clstElement.ItemHeight;

            txtNew.Location = new Point(0, 0);
            if (clstElement.Height <= intHeight)
            {
                txtNew.Width = clstElement.Width - 17;
            }
            else
            {
                txtNew.Width = clstElement.Width;
            }
            txtNew.Height   = clstElement.ItemHeight;
            txtNew.KeyDown += new KeyEventHandler(txtNew_KeyDown);
            txtNew.Leave   += new EventHandler(txtNew_Leave);
            txtNew.Location = rtg.Location;
            txtNew.Text     = clstElement.GetItemText(clstElement.SelectedIndex);
            txtNew.Tag      = clstElement.GetItemValue(clstElement.SelectedIndex);

            clstElement.Controls.Add(txtNew);
            txtNew.BringToFront();
            txtNew.Focus();
        }