exception: onmousedownright on basegridbehaviour

4 posts, 0 answers
  1. Jorge Delgado-Lopez
    Jorge Delgado-Lopez avatar
    82 posts
    Member since:
    Aug 2007

    Posted 17 Dec 2008 Link to this post

    Hi,

    VS2005
    WinControls 2008Q3 1204

    I get a null pointer exception when right clicking on a grid outside the rows. 

    I think I found the bug, if I set the selectionmode to cellselect it works fine.

                if (this.GridControl.MultiSelect && this.GridControl.SelectionMode == GridViewSelectionMode.FullRowSelect)
                {
                    if (!row.IsSelected)
                    {
                        this.GridControl.SelectedRows.Clear();
                    }
                }

    01:05:54:735 10 Exception .... Object reference not set to an instance of an object.
       at Telerik.WinControls.UI.BaseGridBehavior.OnMouseDownRight(MouseEventArgs e)
       at Telerik.WinControls.UI.BaseGridBehavior.OnMouseDown(MouseEventArgs e)
       at Telerik.WinControls.UI.RadGridView.OnMouseDown(MouseEventArgs e)
       at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at Telerik.WinControls.RadControl.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)

    My grid:

                // 
                // radGridView
                // 
                this.radGridView.BackColor = System.Drawing.Color.Transparent;
                this.radGridView.Cursor = System.Windows.Forms.Cursors.Default;
                this.radGridView.Dock = System.Windows.Forms.DockStyle.Fill;
                this.radGridView.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
                this.radGridView.ForeColor = System.Drawing.SystemColors.ControlText;
                this.radGridView.ImeMode = System.Windows.Forms.ImeMode.NoControl;
                this.radGridView.Location = new System.Drawing.Point(0, 0);
                this.radGridView.Margin = new System.Windows.Forms.Padding(0);
                // 
                // 
                // 
                this.radGridView.MasterGridViewTemplate.AllowAddNewRow = false;
                this.radGridView.MasterGridViewTemplate.AllowColumnChooser = false;
                this.radGridView.MasterGridViewTemplate.AllowColumnReorder = false;
                this.radGridView.MasterGridViewTemplate.AllowDragToGroup = false;
                this.radGridView.MasterGridViewTemplate.AllowRowResize = false;
                this.radGridView.MasterGridViewTemplate.Caption = null;
                gridViewTextBoxColumn1.FieldAlias = "FileName";
                gridViewTextBoxColumn1.FieldName = "FileName";
                gridViewTextBoxColumn1.HeaderText = "Name";
                gridViewTextBoxColumn1.HeaderTextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
                gridViewTextBoxColumn1.UniqueName = "FileName";
                gridViewTextBoxColumn1.Width = 160;
                gridViewDateTimeColumn1.DataType = typeof(System.DateTime);
                gridViewDateTimeColumn1.FieldAlias = "DateCreated";
                gridViewDateTimeColumn1.FieldName = "DateCreated";
                gridViewDateTimeColumn1.HeaderText = "Date uploaded";
                gridViewDateTimeColumn1.HeaderTextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
                gridViewDateTimeColumn1.SortOrder = Telerik.WinControls.UI.RadSortOrder.Ascending;
                gridViewDateTimeColumn1.UniqueName = "DateCreated";
                gridViewDateTimeColumn1.Width = 120;
                gridViewTextBoxColumn2.FieldAlias = "FileType";
                gridViewTextBoxColumn2.FieldName = "FileType";
                gridViewTextBoxColumn2.HeaderText = "Type";
                gridViewTextBoxColumn2.HeaderTextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
                gridViewTextBoxColumn2.UniqueName = "FileType";
                gridViewTextBoxColumn2.Width = 110;
                gridViewTextBoxColumn3.FieldAlias = "FileSize";
                gridViewTextBoxColumn3.FieldName = "FileSize";
                gridViewTextBoxColumn3.HeaderText = "Size";
                gridViewTextBoxColumn3.HeaderTextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
                gridViewTextBoxColumn3.UniqueName = "FileSize";
                gridViewTextBoxColumn3.Width = 100;
                this.radGridView.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn1);
                this.radGridView.MasterGridViewTemplate.Columns.Add(gridViewDateTimeColumn1);
                this.radGridView.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn2);
                this.radGridView.MasterGridViewTemplate.Columns.Add(gridViewTextBoxColumn3);
                this.radGridView.MasterGridViewTemplate.EnableGrouping = false;
                this.radGridView.MasterGridViewTemplate.ShowRowHeaderColumn = false;
                this.radGridView.MultiSelect = true;
                this.radGridView.Name = "radGridView";
                this.radGridView.ReadOnly = true;
                this.radGridView.RightToLeft = System.Windows.Forms.RightToLeft.No;
                this.radGridView.ShowGroupPanel = false;
                this.radGridView.Size = new System.Drawing.Size(443, 401);
                this.radGridView.TabIndex = 0;
                this.radGridView.Text = "radGridView";
                this.radGridView.ThemeName = "Vista";
                ((Telerik.WinControls.UI.GridTableElement)(this.radGridView.GetChildAt(0))).CellSpacing = -1;
                ((Telerik.WinControls.UI.GridTableElement)(this.radGridView.GetChildAt(0))).DrawBorder = false;
                ((Telerik.WinControls.UI.GridTableElement)(this.radGridView.GetChildAt(0))).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
                ((Telerik.WinControls.UI.GridTableElement)(this.radGridView.GetChildAt(0))).DrawFill = true;
                ((Telerik.WinControls.UI.GridTableBodyElement)(this.radGridView.GetChildAt(0).GetChildAt(1))).DrawBorder = true;
                ((Telerik.WinControls.UI.GridTableBodyElement)(this.radGridView.GetChildAt(0).GetChildAt(1))).BackColor = System.Drawing.Color.White;
                ((Telerik.WinControls.UI.GridTableBodyElement)(this.radGridView.GetChildAt(0).GetChildAt(1))).DrawFill = false;

    Question. Can I have the drop down show even if there are no rows in the grid? (add row?)

    thanks
    -j

  2. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 19 Dec 2008 Link to this post

    Hi Jorge Delgado-Lopez,

    Thank you for contacting us.

    This is a known issue and will be addressed in the upcoming Q3 2008 SP2 version, scheduled for the second half of January 2009. For the time being, I have prepared a workaround demonstrated in the attached sample project attached. This workaround concerns inheriting from RadGridView and overriding the OnMouseDown method. It will allow you to use FullRowSelect selection mode.

    If you have additional questions, feel free to contact me.

    All the best,
    Nikolay
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. MikeB
    MikeB avatar
    42 posts
    Member since:
    May 2008

    Posted 19 Feb 2009 Link to this post

    Hi,
    I'm having the same problem.  Has Q3 2008 SP2 been released yet?  I don't see it in the Downloads.
    Thanks,
    MikeB
  5. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 19 Feb 2009 Link to this post

    Yes MikeB, Q3 2008 SP2 was released on Jan 21, 2009. You can find it in your account as v2008.3 1321. For additional information, please refer to following Knowledge Base article: Updating RadControls for WinForms to another version or license.
     
    If you have additional questions, feel free to contact me.

    Sincerely yours,
    Nikolay
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top