Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

CalendarColumn error on calling InitializeEditingControl

$
0
0
Hi all,

I saw the sample code for developing a costomized DataGridViewColumn here and I added the class in my application.  It works well for one DataGridView control but not for the other.  The error came from InitializeEditingControl method within CalendarCell class.  It throws ArgumentOutOfRangeException - "Specified argument was out of the range of valid values.\r\nParameter name: rowIndex".  I checked the input value of rowIndex and it was 1 which is all right.  But after calling InitializeEditingControl, this.RowIndex was still -1 which should be 1 also.  I've compared the difference between the two DataGridViews I had on the windows form, but could not find anything that might cause the error.  I am stuckhere.  Does anyone have the same problem before?  Any thought would be helpful to me.  Thanks.

        public override void InitializeEditingControl(int rowIndex, object
            initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
        {
            // Set the value of the editing control to the current cell value.
            base.InitializeEditingControl(rowIndex, initialFormattedValue,
                dataGridViewCellStyle);
            CalendarEditingControl ctl =
                DataGridView.EditingControl as CalendarEditingControl;
            if (this.Value == DBNull.Value)
            {
                ctl.Value = DateTime.Now;
            }
            else
            {
                ctl.Value = (DateTime)this.Value;
            }
        }

Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>