Пример #1
0
 private void dataGridView1_RowDirtyStateNeeded(object sender, System.Windows.Forms.QuestionEventArgs e)
 {
     if (!rowScopeCommit)
     {
         // In cell-level commit scope, indicate whether the value
         // of the current cell has been modified.
         e.Response = this.dataGridView1.IsCurrentCellDirty;
     }
 }
Пример #2
0
 private void dataGridView1_CancelRowEdit(object sender, System.Windows.Forms.QuestionEventArgs e)
 {
     if (this.rowInEdit == this.dataGridView1.Rows.Count - 2 &&
         this.rowInEdit == this.customers.Count)
     {
         // If the user has canceled the edit of a newly created row,
         // replace the corresponding Customer object with a new, empty one.
         this.customerInEdit = new Customer();
     }
     else
     {
         // If the user has canceled the edit of an existing row,
         // release the corresponding Customer object.
         this.customerInEdit = null;
         this.rowInEdit      = -1;
     }
 }
Пример #3
0
 public virtual void dataGrid_CancelRowEdit(QuestionEventArgs e)
 {
     current_editrow = null;
 }
Пример #4
0
 public void dataGrid_CancelRowEdit(QuestionEventArgs e)
 {
     if (current_view == null) return;
     current_view.dataGrid_CancelRowEdit(e);
 }
Пример #5
0
 private void dataGridView1_RowDirtyStateNeeded(object sender, QuestionEventArgs e)
 {
     if (!rowScopeCommit)
     {
         // In cell-level commit scope, indicate whether the value
         // of the current cell has been modified.
         e.Response = this.dataGridView1.IsCurrentCellDirty;
     }
 }
Пример #6
0
		protected virtual void OnCancelRowEdit (QuestionEventArgs e) {
			QuestionEventHandler eh = (QuestionEventHandler)(Events [CancelRowEditEvent]);
			if (eh != null)
				eh (this, e);
		}
Пример #7
0
 void grid_RowDirtyStateNeeded(object sender, QuestionEventArgs e)
 {
     e.Response = dirty;
     Debug.WriteLine(string.Format("Queried dirty state for R{0}C{1}: {2}", grid.CurrentCell.RowIndex, grid.CurrentCell.ColumnIndex, dirty));
 }
        private DataGridViewDataErrorEventArgs CancelEditPrivate(/*ref DataGridViewCell dataGridViewCurrentCell, DataGridViewDataErrorContexts context*/)
        {
            bool currentCellDirty = this.IsCurrentCellDirty;
            bool currentRowDirty = this.IsCurrentRowDirty;

            if (this.IsCurrentCellInEditMode)
            {
                /* Do not push original value back into the cell - VS Whidbey bug 328624
                Exception exception;
                if (!PushFormattedValue(ref dataGridViewCurrentCell, this.uneditedFormattedValue, out exception))
                {
                    Debug.Assert(dataGridViewCurrentCell.RowIndex > -1);
                    DataGridViewDataErrorEventArgs dgvdee = new DataGridViewDataErrorEventArgs(exception, 
                                                                                dataGridViewCurrentCell.ColumnIndex, 
                                                                                dataGridViewCurrentCell.RowIndex, 
                                                                                // dataGridViewCurrentCell.Value,
                                                                                // this.uneditedFormattedValue,
                                                                                context);
                    dgvdee.Cancel = true;
                    OnDataErrorInternal(dgvdee);
                    return dgvdee;
                }
                */
                if (this.editingControl != null)
                {
                    ((IDataGridViewEditingControl)this.editingControl).EditingControlValueChanged = false;
                }
                else
                {
                    Debug.Assert(this.dataGridViewState1[DATAGRIDVIEWSTATE1_currentCellInEditMode]);
                    ((IDataGridViewEditingCell)this.CurrentCellInternal).EditingCellValueChanged = false;
                }
                this.IsCurrentCellDirtyInternal = false;
            }

            if (this.DataSource != null || this.VirtualMode)
            {
                if ((currentRowDirty && !currentCellDirty) || 
                    (this.dataGridViewState1[DATAGRIDVIEWSTATE1_newRowEdited] && 
                    !this.dataGridViewState1[DATAGRIDVIEWSTATE1_editedRowChanged]))
                {
                    bool discardNewRow = this.dataGridViewState1[DATAGRIDVIEWSTATE1_newRowEdited];
                    this.IsCurrentRowDirtyInternal = false;
                    if (this.VirtualMode)
                    {
                        QuestionEventArgs qe = new QuestionEventArgs(discardNewRow);
                        OnCancelRowEdit(qe);
                        discardNewRow &= qe.Response;
                    }
                    if (this.DataSource != null)
                    {
                        int oldCurrentCellX = this.ptCurrentCell.X;
                        this.dataConnection.CancelRowEdit(true /*restoreRow*/, this.dataGridViewState1[DATAGRIDVIEWSTATE1_newRowEdited]/*addNewFinished*/);
                        if (this.dataConnection.List.Count == 0)
                        {
                            // There are no rows left in the back end.
                            if (currentCellDirty || this.ptCurrentCell.Y == -1 || this.ptCurrentCell.X == -1)
                            {
                                if (!IsColumnOutOfBounds(oldCurrentCellX) && this.Columns[oldCurrentCellX].Visible)
                                {
                                    Debug.Assert(0 == this.Rows.GetFirstRow(DataGridViewElementStates.Visible));
                                    // Setting the current cell to the current column in the first row
                                    // will create the new row if the user was editing the cell.
                                    SetAndSelectCurrentCellAddress(oldCurrentCellX,
                                                                   0,
                                                                   true,  /*setAnchorCellAddress*/
                                                                   false, /*validateCurrentCell*/
                                                                   false,  /*throughMouseClick*/
                                                                   true /*clearSelecttion*/,
                                                                   false /*forceCurrentCellSelection (unused)*/);
                                }
                            }
                            else
                            {
                                // Else, simply add a new row.
                                this.dataConnection.OnNewRowNeeded();
                            }
                        }

                        // CancelRowEdit discarded the new row if we were editing the new row.
                        discardNewRow = false;
                    }
                    if (this.ptCurrentCell.Y > -1)
                    {
                        InvalidateRowPrivate(this.ptCurrentCell.Y);
                        DataGridViewCell dataGridViewCell = this.CurrentCellInternal;
                        if (this.IsCurrentCellInEditMode)
                        {
                            DataGridViewCellStyle dataGridViewCellStyle = dataGridViewCell.GetInheritedStyle(null, this.ptCurrentCell.Y, true);
                            if (this.editingControl != null)
                            {
                                InitializeEditingControlValue(ref dataGridViewCellStyle, dataGridViewCell);
                                if (((IDataGridViewEditingControl) this.editingControl).RepositionEditingControlOnValueChange)
                                {
                                    PositionEditingControl(true /*setLocation*/, true /*setSize*/, false /*setFocus*/);
                                }
                            }
                            else
                            {
                                Debug.Assert(this.dataGridViewState1[DATAGRIDVIEWSTATE1_currentCellInEditMode]);
                                InitializeEditingCellValue(ref dataGridViewCellStyle, ref dataGridViewCell);
                            }
                        }
                    }
                    if (discardNewRow && this.ptCurrentCell.Y == this.newRowIndex - 1)
                    {
                        DiscardNewRow();
                    }
                }
            }
            else
            {
                if (!this.IsCurrentRowDirty && 
                    this.ptCurrentCell.Y == this.newRowIndex - 1 &&
                    this.dataGridViewState1[DATAGRIDVIEWSTATE1_newRowCreatedByEditing])
                {
                    DiscardNewRow();
                }
            }
            return null;
        }
 protected virtual void OnRowDirtyStateNeeded(QuestionEventArgs e);
 protected virtual void OnCancelRowEdit(QuestionEventArgs e);
 private void ScheduleGrid_CancelRowEdit(object sender, QuestionEventArgs e) {
     MainWindow_Load(sender, e);
 }
Пример #12
0
 private void dataGridView1_RowDirtyStateNeeded(object sender, QuestionEventArgs e)
 {
 }
 private DataGridViewDataErrorEventArgs CancelEditPrivate()
 {
     bool isCurrentCellDirty = this.IsCurrentCellDirty;
     bool isCurrentRowDirty = this.IsCurrentRowDirty;
     if (this.IsCurrentCellInEditMode)
     {
         if (this.editingControl != null)
         {
             ((IDataGridViewEditingControl) this.editingControl).EditingControlValueChanged = false;
         }
         else
         {
             ((IDataGridViewEditingCell) this.CurrentCellInternal).EditingCellValueChanged = false;
         }
         this.IsCurrentCellDirtyInternal = false;
     }
     if ((this.DataSource != null) || this.VirtualMode)
     {
         if ((isCurrentRowDirty && !isCurrentCellDirty) || (this.dataGridViewState1[0x80000] && !this.dataGridViewState1[0x40000]))
         {
             bool response = this.dataGridViewState1[0x80000];
             this.IsCurrentRowDirtyInternal = false;
             if (this.VirtualMode)
             {
                 QuestionEventArgs e = new QuestionEventArgs(response);
                 this.OnCancelRowEdit(e);
                 response &= e.Response;
             }
             if (this.DataSource != null)
             {
                 int x = this.ptCurrentCell.X;
                 this.dataConnection.CancelRowEdit(true, this.dataGridViewState1[0x80000]);
                 if (this.dataConnection.List.Count == 0)
                 {
                     if ((isCurrentCellDirty || (this.ptCurrentCell.Y == -1)) || (this.ptCurrentCell.X == -1))
                     {
                         if (!this.IsColumnOutOfBounds(x) && this.Columns[x].Visible)
                         {
                             this.SetAndSelectCurrentCellAddress(x, 0, true, false, false, true, false);
                         }
                     }
                     else
                     {
                         this.dataConnection.OnNewRowNeeded();
                     }
                 }
                 response = false;
             }
             if (this.ptCurrentCell.Y > -1)
             {
                 this.InvalidateRowPrivate(this.ptCurrentCell.Y);
                 DataGridViewCell currentCellInternal = this.CurrentCellInternal;
                 if (this.IsCurrentCellInEditMode)
                 {
                     DataGridViewCellStyle dataGridViewCellStyle = currentCellInternal.GetInheritedStyle(null, this.ptCurrentCell.Y, true);
                     if (this.editingControl != null)
                     {
                         this.InitializeEditingControlValue(ref dataGridViewCellStyle, currentCellInternal);
                         if (((IDataGridViewEditingControl) this.editingControl).RepositionEditingControlOnValueChange)
                         {
                             this.PositionEditingControl(true, true, false);
                         }
                     }
                     else
                     {
                         this.InitializeEditingCellValue(ref dataGridViewCellStyle, ref currentCellInternal);
                     }
                 }
             }
             if (response && (this.ptCurrentCell.Y == (this.newRowIndex - 1)))
             {
                 this.DiscardNewRow();
             }
         }
     }
     else if ((!this.IsCurrentRowDirty && (this.ptCurrentCell.Y == (this.newRowIndex - 1))) && this.dataGridViewState1[0x200000])
     {
         this.DiscardNewRow();
     }
     return null;
 }
 protected virtual void OnCancelRowEdit(QuestionEventArgs e)
 {
     QuestionEventHandler handler = base.Events[EVENT_DATAGRIDVIEWCANCELROWEDIT] as QuestionEventHandler;
     if (((handler != null) && !this.dataGridViewOper[0x100000]) && !base.IsDisposed)
     {
         handler(this, e);
         this.CorrectFocus(true);
     }
 }
        /// <summary>
        /// Extends BeginInvoke so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// questioneventhandler.BeginInvoke(sender, e, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginInvoke(this QuestionEventHandler questioneventhandler, Object sender, QuestionEventArgs e, AsyncCallback callback)
        {
            if(questioneventhandler == null) throw new ArgumentNullException("questioneventhandler");

            return questioneventhandler.BeginInvoke(sender, e, callback, null);
        }
 /// <include file='doc\DataGridView.uex' path='docs/doc[@for="DataGridView.OnCancelRowEdit"]/*' />
 protected virtual void OnCancelRowEdit(QuestionEventArgs e)
 {
     QuestionEventHandler eh = this.Events[EVENT_DATAGRIDVIEWCANCELROWEDIT] as QuestionEventHandler;
     if (eh != null && !this.dataGridViewOper[DATAGRIDVIEWOPER_inDispose] && !this.IsDisposed)
     {
         eh(this, e);
         CorrectFocus(true /*onlyIfGridHasFocus*/);
     }
 }
 /// <include file='doc\DataGridView.uex' path='docs/doc[@for="DataGridView.OnRowDirtyStateNeeded"]/*' />
 protected virtual void OnRowDirtyStateNeeded(QuestionEventArgs e)
 {
     QuestionEventHandler eh = this.Events[EVENT_DATAGRIDVIEWROWDIRTYSTATENEEDED] as QuestionEventHandler;
     if (eh != null && !this.dataGridViewOper[DATAGRIDVIEWOPER_inDispose] && !this.IsDisposed)
     {
         eh(this, e);
     }
 }
Пример #18
0
 protected override void OnCancelRowEdit(QuestionEventArgs e)
 {
     base.OnCancelRowEdit(e);
     _pagingBindingSource.CancelEdit();
     _uncommitedRows.Remove(CurrentRow.Index);
 }
Пример #19
0
        void grid_CancelRowEdit(object sender, QuestionEventArgs e)
        {
            if (source == null)
                return;

            //Count-2 because there will be a new extender row, which will be
            //occupying Count-1, thus the currently edited row will be Count-2.
            if (rowInEdit == grid.Rows.Count - 2 && rowInEdit == source.Count) {
                // If the user has canceled the edit of a newly created row,
                // replace the corresponding TranslationPair object with a new, empty one.
                pairInEdit = new WordListEntry(null);
            } else {
                // If the user has canceled the edit of an existing row,
                // release the corresponding TranslationPair object.
                pairInEdit = null;
                rowInEdit = null;
            }
        }
Пример #20
0
 protected override void OnCancelRowEdit(QuestionEventArgs e)
 {
     base.OnCancelRowEdit(e);
       if (Model != null)
     e.Response = (Model.count() < RowCount);
 }
Пример #21
0
 private void dataGridView2_CancelRowEdit(object sender, QuestionEventArgs e)
 {
 }
Пример #22
0
 // cancel row edit
 private void dataGrid_CancelRowEdit(object sender, QuestionEventArgs e)
 {
     Program.main.dataGrid_CancelRowEdit(e);
 }
        //method: ConnectionReader
        //description: reads data from the server
        //params: none
        //returns: void
        private void ConnectionReader()
        {
            try {
                while(!stopped) {
                    if(reader.PeekLine().StartsWith("QUESTION:")) {//QUESTION

                        //get question
                        QuestionEventArgs question = new QuestionEventArgs();
                        question.questionText = reader.ReadLine().Substring("QUESTION:".Length);

                        //get answers
                        question.answers = new List<string>();
                        while(reader.PeekLine().StartsWith("ANSWER:")) {
                            question.answers.Add(reader.ReadLine().Substring("ANSWER:".Length));
                        }

                        question.timeLimit = int.Parse(reader.ReadLine().Substring("TIME:".Length));

                        owner.Invoke((MethodInvoker)(
                            () => { QuestionReceived(this, question); }
                        ));

                    } else if(reader.PeekLine().StartsWith("RESULT:")) {//QUESTION RESULTS
                        List<QuestionResult> results = new List<QuestionResult>();

                        while(reader.PeekLine().StartsWith("RESULT:")) {

                            QuestionResult r = new QuestionResult();
                            r.questionText = reader.ReadLine().Substring("RESULT:".Length);
                            r.correctAnswer = reader.ReadLine();
                            r.userAnswer = reader.ReadLine();
                            r.score = int.Parse(reader.ReadLine());

                            results.Add(r);

                        }

                        owner.Invoke((MethodInvoker)(
                            () => { ResultsReceived(this, results); }
                        ));

                    } else if(reader.PeekLine().StartsWith("SESSIONID:")) {//LEADERBOARD
                        List<UserSession> rows = new List<UserSession>();

                        while(reader.PeekLine() != null && reader.PeekLine().StartsWith("SESSIONID:")) {

                            UserSession r = new UserSession();

                            r.sessionId = int.Parse(reader.ReadLine().Substring("SESSIONID:".Length));
                            r.userName = reader.ReadLine().Substring("USERNAME:"******"SCORE:".Length));

                            rows.Add(r);

                        }

                        owner.Invoke((MethodInvoker)(
                            () => { LeaderboardReceived(this, rows); }
                        ));
                    } else if(reader.PeekLine().StartsWith("YOUR_SESSIONID:")) {

                        int sessionId = int.Parse(reader.ReadLine().Substring("YOUR_SESSIONID:".Length));

                        owner.Invoke((MethodInvoker)(
                            () => { SessionIdReceived(this, sessionId); }
                        ));
                    } else {
                        //nothing we can handle
                        reader.ReadLine();//consume
                    }

                    Thread.Sleep(50);
                }
            } catch (Exception ex) {
                if(ex is ArgumentException || ex is SocketException || ex is IOException || ex is NullReferenceException) {
                    stopped = true;
                    owner.Invoke((MethodInvoker)(
                        () => { ConnectionLost(this, new EventArgs()); }
                    ));
                } else {
                    throw;
                }
            } finally {
                socket.Close();
            }
        }
Пример #24
0
 private void dgvAppParameter_CancelRowEdit(object sender, QuestionEventArgs e)
 {
     SetModifyStatus(false);
 }
Пример #25
0
		protected virtual void OnRowDirtyStateNeeded (QuestionEventArgs e)
		{
			QuestionEventHandler eh = (QuestionEventHandler)(Events [RowDirtyStateNeededEvent]);
			if (eh != null) eh (this, e);
		}
Пример #26
0
    private void dataGridView1_CancelRowEdit(object sender, QuestionEventArgs e)
    {
        if (this.rowInEdit == this.dataGridView1.Rows.Count - 2 &&
this.rowInEdit == this.CanData.Count)
        {
            // If the user has canceled the edit of a newly created row, 
            // replace the corresponding CANDATA object with a new, empty one.
            this.CANDATAInEdit = new CANDATA();
        }
        else
        {
            // If the user has canceled the edit of an existing row, 
            // release the corresponding CANDATA object.
            this.CANDATAInEdit = null;
            this.rowInEdit = -1;
        }
    }