Example #1
0
        protected override void OnCellEndEdit(DataGridViewCellEventArgs e)
        {
            String nowText = this.CurrentCell.Value as String;

            CellTextChangedEventArgs args = new CellTextChangedEventArgs(BeforeText, nowText, Now.Col, Now.Row, this.Rows[Now.Row], this.Rows[Now.Row].Cells[Now.Col] as DataGridViewTextBoxCell);

            if (_isEditActivated)
            {
                if (BeforeText.Equals(nowText) == false)
                {
                    if (E_TextChanged != null)
                    {
                        E_TextChanged(this, args);
                    }
                    if (args.IsCancel)
                    {
                        if (EditingControl != null)
                        {
                            this.EditingControl.Text = BeforeText;
                        }
                        Cell(Now).Value = BeforeText;
                    }
                }
                if (E_TextEditFinished != null)
                {
                    E_TextEditFinished(this, args);
                }
                _isEditActivated = false;
            }
            base.OnCellEndEdit(e);
        }
Example #2
0
        void V_Contents_E_TextChanged(object sender, CellTextChangedEventArgs e)
        {
            int           itemIndex  = (int)V_Contents.Rows[e.RowIndex].RelativeObject[rowInfos.itemIndex.ToString()];
            int           valueIndex = (int)V_Contents.Rows[e.RowIndex].RelativeObject[rowInfos.valueIndex.ToString()];
            CPacketStruct parser     = V_Contents.Rows[e.RowIndex].RelativeObject[rowInfos.parser.ToString()] as CPacketStruct;

            switch ((contentTitles)e.ColIndex)
            {
            case contentTitles.name:
                if (e.Text.Length == 0)    //아무것도 넣지않으면 자동으로 복귀
                {
                    e.IsCancel = true;
                    return;
                }
                else if (Char.IsDigit(e.Text[0]))
                {
                    MessageBox.Show("변수명의 처음은 문자로 시작해야 합니다.");
                    e.IsCancel = true;
                    return;
                }
                else
                {
                    for (int i = 0; i < e.Text.Length; i++)
                    {
                        if (Char.IsLetterOrDigit(e.Text, i) == false)
                        {
                            MessageBox.Show("변수명에는 문자와 숫자만 들어갈 수 있습니다.");
                            e.IsCancel = true;
                            return;
                        }
                    }
                    for (int i = 0; i < parser.Items.Count; i++)
                    {
                        if (parser.Items[i].Name.Equals(e.Text))
                        {
                            MessageBox.Show("같은 이름이 존재합니다.");
                            e.IsCancel = true;
                            return;
                        }
                    }
                }
                parser.Items[itemIndex].Name = e.Text;

                if (parser.Items[itemIndex].InitValues.Length > 1) //배열일 때,
                {
                    viewContent(parser);                           //목록을 다시 만듬.
                }

                break;

            case contentTitles.value:
                parser.Items[itemIndex].InitValues[valueIndex] = e.Text;
                break;
            }
            parser.MakePacket(_endian == Endians.Big);
            parser.MakeMsgText();
            String name = V_Contents.RelativeObject["name"] as String;

            _modifiedItems[name] = parser;
        }
 void XmlScenarioTable_E_TextChanged(object sender, CellTextChangedEventArgs e)
 {
     _currentCell     = Cell(e.RowIndex, e.ColIndex) as IEasyGridCell;
     _textChangedArgs = e;
     if (_currentCell != null)
     {
         XmlControlHandler.RunEvent(this, "OnTextChanged");
     }
 }
Example #4
0
        /*
         * protected override void OnCellMouseClick(DataGridViewCellMouseEventArgs e)
         * {
         *  try
         *  {
         *      if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
         *      {
         *          Now.Set(e.RowIndex, e.ColumnIndex);
         *          if (Before.Col >= 0 && Before.Row >= 0)
         *          {
         *
         *              this.Rows[Before.Row].Cells[Before.Col].Selected = false;
         *          }
         *          Before.Set(Now);
         *          this.CurrentCell = this.Rows[e.RowIndex].Cells[e.ColumnIndex];
         *          this.CurrentCell.Selected = true;
         *      }
         *  }
         *  catch { }
         *  base.OnCellMouseClick(e);
         * }
         */
        protected override void OnCellLeave(DataGridViewCellEventArgs e)
        {//cell을 떠나는 경우는 CurrentCell이 있는 경우이다.
         //있을 수 있는경우의 수는, 세 가지이다.
         //마우스로 인하여 이전에서 옮겨지는 경우, Before가 의미가 없어진다.
         //키보드의 방향키로 인해 위치가 옮겨지는 경우, 역시 Before의 의미가 없다.
         //Enter로 그 자신의 위치로 다시 옮겨지는 경우에만 Before가 의미가 있다.

            if (_goBack)
            {
                Before.Set(e.RowIndex, e.ColumnIndex);
            }
            if (this.EditingControl != null && _isEditActivated)      //편집모드였다가 나갈 때는 값이 갱신되었다면 이벤트를 호출시킨다.
            {
                String nowText = this.EditingControl.Text.ToString(); // this.CurrentCell.Value.ToString();
                this.CurrentCell.Value = nowText;
                if (_isEditActivated)
                {
                    CellTextChangedEventArgs args = new CellTextChangedEventArgs(BeforeText, nowText, Before.Col, Before.Row, this.Rows[Before.Row], this.Rows[Before.Row].Cells[Before.Col] as DataGridViewTextBoxCell);
                    if (BeforeText.Equals(nowText) == false)
                    {
                        if (E_TextChanged != null)
                        {
                            E_TextChanged(this, args);
                        }
                        if (args.IsCancel)
                        {
                            this.EditingControl.Text = BeforeText;
                        }
                    }
                    if (E_TextEditFinished != null)
                    {
                        E_TextEditFinished(this, args);
                    }
                    _isEditActivated = false;
                }
            }

            /*
             * if (this.EditingControl == null && _isEditing)
             * {
             *  if (ActionOnEnterInEditMode == EnterActions.EditNextColumn)
             *  {
             *
             *  }
             *  else if (ActionOnEnterInEditMode == EnterActions.EditNextRow)
             *  {
             *  }
             *  else //ActionOnEnterInEditMode == EnterActions.EditOnThePosition
             *  {
             *
             *          return;
             *  }
             * }
             */
            /*
             * if (Now.Row >= 0 && Now.Col >= 0)
             * {
             *
             *  if (this.CurrentCell!=null && this.CurrentCell is DataGridViewTextBoxCell)
             *  {
             *      if (_isEditing && this.EditingControl!=null)
             *      {
             *          String nowText = this.EditingControl.Text.ToString();// this.CurrentCell.Value.ToString();
             *          this.CurrentCell.Value = nowText;
             *          if (_isEditActivated)
             *          {
             *              CellTextChangedEventArgs args = new CellTextChangedEventArgs(BeforeText, nowText, Before.Col, Before.Row, this.Rows[Before.Row], this.Rows[Before.Row].Cells[Before.Col] as DataGridViewTextBoxCell);
             *              if (BeforeText.Equals(nowText) == false)
             *              {
             *                  if (E_TextChanged != null) E_TextChanged(this, args);
             *
             *              }
             *              if (E_TextEditFinished != null) E_TextEditFinished(this, args);
             *              _isEditActivated = false;
             *          }
             *      }
             *  }
             *  if(_posAfterEdit!=_posAfterEdit) Before.Set(Now);
             *
             * }
             * else
             * {
             *  Before.Set(e.RowIndex, e.ColumnIndex);
             * }
             */
            base.OnCellLeave(e);
        }