After upgrading to version 2010 Q3 SP1 (2010.3.10.1215), getting System.NullReferenceException

24 posts, 1 answers
  1. AaronP
    AaronP avatar
    26 posts
    Member since:
    Apr 2010

    Posted 26 Jan 2011 Link to this post

    I have a 3 level hierarchical grid and I am getting the following error when I try to edit an expanded child row:

    System.NullReferenceException was unhandled
    Message="Object reference not set to an instance of an object."
    Source="Telerik.WinControls.GridView"
    StackTrace:
    at Telerik.WinControls.UI.GridViewEditManager.InitializeEditor(IInputEditor activeEditor)
    at Telerik.WinControls.UI.GridViewEditManager.BeginEdit()
    at Telerik.WinControls.UI.GridRowBehavior.OnMouseUpLeft(MouseEventArgs e)
    at Telerik.WinControls.UI.GridRowBehavior.OnMouseUp(MouseEventArgs e)
    at Telerik.WinControls.UI.BaseGridBehavior.OnMouseUp(MouseEventArgs e)
    at Telerik.WinControls.UI.RadGridView.OnMouseUp(MouseEventArgs e)
    at System.Windows.Forms.Control.WmMouseUp(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.Application.Run(Form mainForm)
    at CU_Estimating_v2.Program.Main() in C:\Documents and Settings\APahlka\My Documents\Visual Studio 2008\Projects\CU_Estimating_v2\CU_Estimating_v2\Program.cs:line 23
    at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()
    InnerException:

    If the row is not expanded, then I don't get the error. The grid looks something like this when the error occurs:
    - Parent
      - Child (trying to edit and get’s error) 
         Grandchild

    I don’t get it when the child row is not expanded like this:
    - Parent
    + Child (trying to edit and no error)

    I'm trying to duplicate it on a smaller project, but I have not been able to yet.

    Do you have any suggestions to try?

    Thank you,
    Aaron
  2. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 26 Jan 2011 Link to this post

    Hello,

    My first thought is, is that you are accidentally still referencing one of the old assemblies. Ensure that you are no longer referencing any of the old Telerik dlls in your project by re-adding the references.
    Let me know if that helps or if you need further advice
    Rgards,
    Richard
  3. AaronP
    AaronP avatar
    26 posts
    Member since:
    Apr 2010

    Posted 26 Jan 2011 Link to this post

    Richard,

    I removed the references and re-added them, and I still have the same problem.  I also want to clarify when the error occurs.  It happens when a child row is expanded and I click on the child row cell I want to edit verses the error occurring after editing the child cell.

    Thanks,
    Aaron
  4. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 26 Jan 2011 Link to this post

    Hi again,

    Are you doing anything on background / worker threads to populate the grid or similar? You may want to take a look at that if you are. I know you're having trouble replicating it, but if you can, then please post your sample here and I'll be happy to take a look at it.

    Regards,
    Richard
  5. AaronP
    AaronP avatar
    26 posts
    Member since:
    Apr 2010

    Posted 26 Jan 2011 Link to this post

    Hi Richard,

    I'm not doing any background loading and I finally got a sample that behaves similar (but not quite the same)

    Here is my sample code:

    public Form1()
           {
               InitializeComponent();
                 
               #region Setup of GridView
               this.radGridView1.ReadOnly = false;
               this.radGridView1.AutoGenerateHierarchy = true;            
                 
               #region Populate Data
               // load primary data source
               People.Add(new Person(1, 101, "Bob", 204.50M, 1));
               People.Add(new Person(2, 102, "Rob", 208.00M, 1));
               People.Add(new Person(3, 103, "Eric", 300.00M, 1));
               GridViewTemplate carTemplate = new GridViewTemplate();
               Cars.Add(new Car(101, 1, "Ford", 100.50M, 1));
               Cars.Add(new Car(102, 2, "BMW", 104, 1));
               Cars.Add(new Car(102, 6, "BMW", 104, 1));
               Cars.Add(new Car(102, 7, "BMW", 104, 1));
               Cars.Add(new Car(102, 3, "Mazda", 100, 1));
               Cars.Add(new Car(102, 8, "Mazda", 100, 1));
               Cars.Add(new Car(102, 4, "Merc", 100, 1));
               Cars.Add(new Car(103, 5, "Honda", 100, 1));
               carTemplate.DataSource = Cars;
               GridViewTemplate carYearTemplate = new GridViewTemplate();
               CarYears.Add(new CarYear(1, 2004, "Ford", 100));
               CarYears.Add(new CarYear(2, 2000, "BMW", 104));
               CarYears.Add(new CarYear(2, 2001, "BMW", 104));
               CarYears.Add(new CarYear(2, 2002, "BMW", 104));
               CarYears.Add(new CarYear(2, 2003, "BMW", 104));
               CarYears.Add(new CarYear(2, 2004, "BMW", 104));
               CarYears.Add(new CarYear(2, 2005, "BMW", 104));
               CarYears.Add(new CarYear(3, 2004, "Mazda", 100));
               CarYears.Add(new CarYear(4, 2007, "Merc", 100));
               CarYears.Add(new CarYear(5, 2010, "Honda", 100));
               CarYears.Add(new CarYear(6, 2004, "M3", 100));
               CarYears.Add(new CarYear(7, 2011, "M3", 100));
               CarYears.Add(new CarYear(8, 2000, "Mazda", 100));
               CarYears.Add(new CarYear(8, 2001, "Mazda", 100));
               CarYears.Add(new CarYear(8, 2002, "Mazda", 100));
               CarYears.Add(new CarYear(8, 2003, "Mazda", 100));
               CarYears.Add(new CarYear(8, 2004, "Mazda", 100));
               CarYears.Add(new CarYear(8, 2005, "Mazda", 100));
               CarYears.Add(new CarYear(8, 2006, "Mazda", 100));
               CarYears.Add(new CarYear(8, 2007, "Mazda", 100));
               carYearTemplate.DataSource = CarYears;
                
               this.radGridView1.DataSource = People;
               #endregion
               #region Create Relationships
               // Now create first relation
               GridViewRelation carsRelation = new GridViewRelation(this.radGridView1.MasterTemplate);
               carsRelation.ChildTemplate = carTemplate;
               carsRelation.RelationName = "ParentChild";
               carsRelation.ParentColumnNames.Add("ID2");
               carsRelation.ChildColumnNames.Add("ID");
               this.radGridView1.Relations.Add(carsRelation);
               GridViewRelation carYearsRelation = new GridViewRelation(carTemplate, carYearTemplate);
               carYearsRelation.RelationName = "ChildGrandChild";
               carYearsRelation.ParentColumnNames.Add("ID2");
               carYearsRelation.ChildColumnNames.Add("ID");
               this.radGridView1.Relations.Add(carYearsRelation);
                 
               carTemplate.BestFitColumns();
               carTemplate.Caption = "Cars";
                 
               carYearTemplate.BestFitColumns();
               carYearTemplate.Caption = "CarYears";
               #endregion
                 
               this.radGridView1.MasterTemplate.Templates.Add(carTemplate);
               this.radGridView1.MasterTemplate.Templates[0].Templates.Add(carYearTemplate);
                 
               this.radGridView1.MasterTemplate.Templates[0].AllowAddNewRow = false;
               this.radGridView1.MasterTemplate.Templates[0].Templates[0].AllowAddNewRow = false;
               this.radGridView1.MasterTemplate.ChildGridViewTemplates[0].Columns["ID"].IsVisible = false;
               this.radGridView1.MasterTemplate.ChildGridViewTemplates[0].Columns["ID2"].IsVisible = false;
               this.radGridView1.MasterTemplate.ChildGridViewTemplates[0].Columns["Model"].Width = 150;
               this.radGridView1.MasterTemplate.ChildGridViewTemplates[0].Columns["Model"].ReadOnly = true;
               this.radGridView1.MasterTemplate.ChildGridViewTemplates[0].Columns["Qty"].Width = 150;
               this.radGridView1.MasterTemplate.ChildGridViewTemplates[0].Columns["Price"].Width = 150;
               this.radGridView1.MasterTemplate.ChildGridViewTemplates[0].ChildGridViewTemplates[0].Columns["ID"].IsVisible = false;
               this.radGridView1.MasterTemplate.ChildGridViewTemplates[0].ChildGridViewTemplates[0].Columns["Model"].IsVisible = false;
               this.radGridView1.MasterTemplate.ChildGridViewTemplates[0].ChildGridViewTemplates[0].Columns["Year"].Width = 150;
               this.radGridView1.MasterTemplate.ChildGridViewTemplates[0].ChildGridViewTemplates[0].Columns["Price"].Width = 150;
               this.radGridView1.MasterTemplate.ChildGridViewTemplates[0].ChildGridViewTemplates[0].Columns["Year"].ReadOnly = true;
               this.radGridView1.MasterView.ChildRows[1].IsExpanded = true;
               this.radGridView1.MasterView.ChildRows[1].ChildRows[0].IsExpanded = true;
               #endregion
           }

    Create a form and place a radgridview control on it.  Whenever I try and update the price on the grandchild I get the null exception error.

    Let me know if you get the same thing.

    Thank you for your help so far,
    Aaron
  6. AaronP
    AaronP avatar
    26 posts
    Member since:
    Apr 2010

    Posted 26 Jan 2011 Link to this post

    I forgot, in the radgridview control properties I have:

    AutoGenerateColumns = False
    AutoGenerateHierarchy - True
    AutoSizeRows = True
    EnableAlternatingRowColor = True

    I believe it's the AutoSizeRows = True that is causing the error.

    Thanks,
    Aaron
  7. AaronP
    AaronP avatar
    26 posts
    Member since:
    Apr 2010

    Posted 26 Jan 2011 Link to this post

    I just realized I did not give the classes I used in my sample, so here they are:

    public class Person
        {
            public int ID { get; set; }
            public int ID2 { get; set; }
            public string Name { get; set; }
            public decimal Price { get; set; }
            public decimal Qty { get; set; }
      
            public Person(int id, int id2, string name, decimal price, decimal qty)
            {
                ID = id;
                ID2 = id2;
                Name = name;
                Price = price;
                Qty = qty;
            }
        }
       
        public class Car
        {
            public int ID { get; set; }       
            public int ID2 { get; set; }        
            public string Model { get; set; }        
            public int Qty { get; set; }        
            public decimal Price { get; set; }
      
            public Car(int id, int id2, string model, decimal price, int qty)
            {
                ID = id;
                ID2 = id2;
                Model = model;
                Qty = qty;
                Price = price;
            }
        }
         
        public class CarYear
        {
            public int ID { get; set; }        
            public string Model { get; set; }        
            public int Year { get; set; }
            public int Price { get; set; }
      
            public CarYear(int id, int year, string model, int price)
            {
                ID = id;
                Year = year;
                Model = model;
                Price = price;
            }
        }
  8. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 27 Jan 2011 Link to this post

    Morning,

    After a little tweaking, this now works for me. Please can you try it.

    Designer File
    namespace RadGridView_hierarchy_C
    {
        partial class Form1
        {
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components;
      
            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
      
            #region Windows Form Designer generated code
      
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.radGridView1 = new Telerik.WinControls.UI.RadGridView();
                ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).BeginInit();
                this.SuspendLayout();
                // 
                // radGridView1
                // 
                this.radGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
                this.radGridView1.Location = new System.Drawing.Point(0, 0);
                this.radGridView1.Name = "radGridView1";
                this.radGridView1.Size = new System.Drawing.Size(470, 384);
                this.radGridView1.TabIndex = 0;
                this.radGridView1.Text = "radGridView1";
                // 
                // Form1
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(470, 384);
                this.Controls.Add(this.radGridView1);
                this.Name = "Form1";
                this.Text = "Form1";
                ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).EndInit();
                this.ResumeLayout(false);
      
            }
      
            #endregion
      
            private Telerik.WinControls.UI.RadGridView radGridView1;
        }
    }

    Form1.cs
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using Telerik.WinControls;
    using Telerik.WinControls.UI;
    using Telerik.WinControls.RadControlSpy;
      
    namespace RadGridView_hierarchy_C
    {
        public partial class Form1 : Form
        {
              
      
            public Form1()
            {
                InitializeComponent();
      
      
      
                this.Load += new System.EventHandler(this.Form1_Load);
      
            }
      
            private void Form1_Load(object sender, EventArgs e)
            {
      
                List<Person> People = new List<Person>();
                List<Car> Cars = new List<Car>();
                List<CarYear> CarYears = new List<CarYear>();
      
                // load primary data source 
                People.Add(new Person(1, 101, "Bob", 204.50M, 1));
                People.Add(new Person(2, 102, "Rob", 208.00M, 1));
                People.Add(new Person(3, 103, "Eric", 300.00M, 1));
                this.radGridView1.DataSource = People;
      
                GridViewTemplate carTemplate = new GridViewTemplate();
                Cars.Add(new Car(101, 1, "Ford", 100.50M, 1));
                Cars.Add(new Car(102, 2, "BMW", 104, 1));
                Cars.Add(new Car(102, 6, "BMW", 104, 1));
                Cars.Add(new Car(102, 7, "BMW", 104, 1));
                Cars.Add(new Car(102, 3, "Mazda", 100, 1));
                Cars.Add(new Car(102, 8, "Mazda", 100, 1));
                Cars.Add(new Car(102, 4, "Merc", 100, 1));
                Cars.Add(new Car(103, 5, "Honda", 100, 1));
                carTemplate.DataSource = Cars;
      
      
                GridViewTemplate carYearTemplate = new GridViewTemplate();
                CarYears.Add(new CarYear(1, 2004, "Ford", 100));
                CarYears.Add(new CarYear(2, 2000, "BMW", 104));
                CarYears.Add(new CarYear(2, 2001, "BMW", 104));
                CarYears.Add(new CarYear(2, 2002, "BMW", 104));
                CarYears.Add(new CarYear(2, 2003, "BMW", 104));
                CarYears.Add(new CarYear(2, 2004, "BMW", 104));
                CarYears.Add(new CarYear(2, 2005, "BMW", 104));
                CarYears.Add(new CarYear(3, 2004, "Mazda", 100));
                CarYears.Add(new CarYear(4, 2007, "Merc", 100));
                CarYears.Add(new CarYear(5, 2010, "Honda", 100));
                carYearTemplate.DataSource = CarYears;
      
      
                // Now create first relation 
                GridViewRelation carsRelation = new GridViewRelation(this.radGridView1.MasterTemplate);
                carsRelation.ChildTemplate = carTemplate;
                carsRelation.RelationName = "ParentChild";
                carsRelation.ParentColumnNames.Add("ID2");
                carsRelation.ChildColumnNames.Add("ID");
                this.radGridView1.Relations.Add(carsRelation);
      
                GridViewRelation carYearsRelation = new GridViewRelation(carTemplate, carYearTemplate);
                carYearsRelation.RelationName = "ChildGrandChild";
                carYearsRelation.ParentColumnNames.Add("ID2");
                carYearsRelation.ChildColumnNames.Add("ID");
                this.radGridView1.Relations.Add(carYearsRelation);
      
                this.radGridView1.MasterTemplate.Templates.Add(carTemplate);
                this.radGridView1.MasterTemplate.Templates[0].Templates.Add(carYearTemplate);
      
                this.radGridView1.MasterTemplate.Templates[0].AllowAddNewRow = false;
                this.radGridView1.MasterTemplate.Templates[0].Templates[0].AllowAddNewRow = false;
      
      
                this.radGridView1.MasterTemplate.Templates[0].Columns["ID"].IsVisible = false;
                this.radGridView1.MasterTemplate.Templates[0].Columns["ID2"].IsVisible = false;
                this.radGridView1.MasterTemplate.Templates[0].Columns["Model"].Width = 150;
                this.radGridView1.MasterTemplate.Templates[0].Columns["Model"].ReadOnly = true;
                this.radGridView1.MasterTemplate.Templates[0].Columns["Qty"].Width = 150;
                this.radGridView1.MasterTemplate.Templates[0].Columns["Price"].Width = 150;
                this.radGridView1.MasterTemplate.Templates[0].Templates[0].Columns["ID"].IsVisible = false;
                this.radGridView1.MasterTemplate.Templates[0].Templates[0].Columns["Model"].IsVisible = false;
                this.radGridView1.MasterTemplate.Templates[0].Templates[0].Columns["Year"].Width = 150;
                this.radGridView1.MasterTemplate.Templates[0].Templates[0].Columns["Year"].ReadOnly = true;
                  
                this.radGridView1.MasterView.ChildRows[1].IsExpanded = true;
                this.radGridView1.MasterView.ChildRows[1].ChildRows[0].IsExpanded = true;
      
                  
      
                this.radGridView1.AutoGenerateColumns = false;
                this.radGridView1.AutoSizeRows = true;
                this.radGridView1.EnableAlternatingRowColor = true;
                this.radGridView1.ReadOnly = false;
                this.radGridView1.AutoGenerateHierarchy = false;
            }
      
        }
      
      
        public class Person
        {
            public int ID { get; set; }
            public int ID2 { get; set; }
            public string Name { get; set; }
            public decimal Price { get; set; }
            public decimal Qty { get; set; }
      
            public Person(int id, int id2, string name, decimal price, decimal qty)
            {
                ID = id;
                ID2 = id2;
                Name = name;
                Price = price;
                Qty = qty;
            }
        }
      
        public class Car
        {
            public int ID { get; set; }
            public int ID2 { get; set; }
            public string Model { get; set; }
            public int Qty { get; set; }
            public decimal Price { get; set; }
      
            public Car(int id, int id2, string model, decimal price, int qty)
            {
                ID = id;
                ID2 = id2;
                Model = model;
                Qty = qty;
                Price = price;
            }
        }
      
        public class CarYear
        {
            public int ID { get; set; }
            public string Model { get; set; }
            public int Year { get; set; }
            public int Price { get; set; }
      
            public CarYear(int id, int year, string model, int price)
            {
                ID = id;
                Year = year;
                Model = model;
                Price = price;
            }
        }
      
    }

    Hope that helps
    Richard
  9. AaronP
    AaronP avatar
    26 posts
    Member since:
    Apr 2010

    Posted 27 Jan 2011 Link to this post

    Hi Richard,

    I gave it a try and your version works as expected.  I am wondering if you where able to duplicate my error with the code I sent and what you did to tweak it.  It seems on my main application if I set AutoSizeRows = false then it does not have the error.  

    If you did duplicate my error, then I should open a support ticket  and attach my project.

    Thank you for you help,
    Aaron
  10. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 27 Jan 2011 Link to this post

    Hi again,

    At the moment, I'm not able to replicate your error. As you see, I have AutoSizeRows set to true. It's true to say that there is an issue logged with Telerik regarding AutoSize Rows, but as I'm using it, I don't think this is an issue here.

    I changed the order of the code a little as when I first ran it, there were no child rows at all. After changing the order a little, and also changing :
    this.radGridView1.MasterTemplate.Templates[0].Columns["Model"].Width = 150;
    and other similar lines where you were referencing an obsolete template property, it worked fine.

    I'd suggest altering your main application to match the layout of my sample if you can.
    Let me know if you need more help though
    Richard
  11. AaronP
    AaronP avatar
    26 posts
    Member since:
    Apr 2010

    Posted 27 Jan 2011 Link to this post

    Can you try replacing your InitializeComponent() code in your form1.Designer.cs file:
    I find that you sample will now crash.  If it does for you let me know. 


    private void InitializeComponent()
    {
        Telerik.WinControls.UI.GridViewDecimalColumn gridViewDecimalColumn1 = new Telerik.WinControls.UI.GridViewDecimalColumn();
        Telerik.WinControls.UI.GridViewDecimalColumn gridViewDecimalColumn2 = new Telerik.WinControls.UI.GridViewDecimalColumn();
        Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn1 = new Telerik.WinControls.UI.GridViewTextBoxColumn();
        Telerik.WinControls.UI.GridViewDecimalColumn gridViewDecimalColumn3 = new Telerik.WinControls.UI.GridViewDecimalColumn();
        Telerik.WinControls.UI.GridViewDecimalColumn gridViewDecimalColumn4 = new Telerik.WinControls.UI.GridViewDecimalColumn();
        this.radGridView1 = new Telerik.WinControls.UI.RadGridView();
        ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).BeginInit();
        ((System.ComponentModel.ISupportInitialize)(this.radGridView1.MasterTemplate)).BeginInit();
        this.SuspendLayout();
        // 
        // radGridView1
        // 
        this.radGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                    | System.Windows.Forms.AnchorStyles.Left)
                    | System.Windows.Forms.AnchorStyles.Right)));
        this.radGridView1.Location = new System.Drawing.Point(12, 35);
        // 
        // radGridView1
        // 
        this.radGridView1.MasterTemplate.AllowAddNewRow = false;
        gridViewDecimalColumn1.DecimalPlaces = 0;
        gridViewDecimalColumn1.FieldName = "ID";
        gridViewDecimalColumn1.FormatString = "";
        gridViewDecimalColumn1.HeaderText = "ID";
        gridViewDecimalColumn1.IsVisible = false;
        gridViewDecimalColumn1.Name = "ID";
        gridViewDecimalColumn1.TextAlignment = System.Drawing.ContentAlignment.MiddleRight;
        gridViewDecimalColumn2.DecimalPlaces = 0;
        gridViewDecimalColumn2.FieldName = "ID2";
        gridViewDecimalColumn2.FormatString = "";
        gridViewDecimalColumn2.HeaderText = "ID2";
        gridViewDecimalColumn2.IsVisible = false;
        gridViewDecimalColumn2.Name = "ID2";
        gridViewDecimalColumn2.TextAlignment = System.Drawing.ContentAlignment.MiddleRight;
        gridViewTextBoxColumn1.FieldName = "Name";
        gridViewTextBoxColumn1.FormatString = "";
        gridViewTextBoxColumn1.HeaderText = "Name";
        gridViewTextBoxColumn1.Name = "Name";
        gridViewTextBoxColumn1.ReadOnly = true;
        gridViewTextBoxColumn1.Width = 100;
        gridViewDecimalColumn3.FieldName = "Price";
        gridViewDecimalColumn3.FormatString = "";
        gridViewDecimalColumn3.HeaderText = "Price";
        gridViewDecimalColumn3.Name = "Price";
        gridViewDecimalColumn3.TextAlignment = System.Drawing.ContentAlignment.MiddleRight;
        gridViewDecimalColumn3.Width = 150;
        gridViewDecimalColumn4.DecimalPlaces = 0;
        gridViewDecimalColumn4.FieldName = "Qty";
        gridViewDecimalColumn4.FormatString = "";
        gridViewDecimalColumn4.HeaderText = "Qty";
        gridViewDecimalColumn4.Maximum = new decimal(new int[] {
            100,
            0,
            0,
            0});
        gridViewDecimalColumn4.Minimum = new decimal(new int[] {
            1,
            0,
            0,
            0});
        gridViewDecimalColumn4.Name = "Qty";
        gridViewDecimalColumn4.TextAlignment = System.Drawing.ContentAlignment.MiddleRight;
        gridViewDecimalColumn4.Width = 150;
        this.radGridView1.MasterTemplate.Columns.AddRange(new Telerik.WinControls.UI.GridViewDataColumn[] {
            gridViewDecimalColumn1,
            gridViewDecimalColumn2,
            gridViewTextBoxColumn1,
            gridViewDecimalColumn3,
            gridViewDecimalColumn4});
        this.radGridView1.Name = "radGridView1";
        this.radGridView1.Padding = new System.Windows.Forms.Padding(0, 0, 0, 1);
        // 
        // 
        // 
        this.radGridView1.RootElement.Padding = new System.Windows.Forms.Padding(0, 0, 0, 1);
        this.radGridView1.Size = new System.Drawing.Size(604, 379);
        this.radGridView1.TabIndex = 0;
        this.radGridView1.Text = "radGridView1";
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(628, 426);
        this.Controls.Add(this.radGridView1);
        this.Name = "Form1";
        this.Text = "Form1";
        //this.Load += new System.EventHandler(this.Form1_Load);
        ((System.ComponentModel.ISupportInitialize)(this.radGridView1.MasterTemplate)).EndInit();
        ((System.ComponentModel.ISupportInitialize)(this.radGridView1)).EndInit();
          
        this.ResumeLayout(false);
    }
  12. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 27 Jan 2011 Link to this post

    Hello,

    Yes, I can replicate your issue with this code replaced. I'll see what I can find out for you.
    Regards,
    Richard
  13. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 27 Jan 2011 Link to this post

    Hi Again,

    Ok, please remove the following three lines form the designer file. It will then work ok. If you re-add any of these lines then it throws an exception

    // removed from designer
    //this.radGridView1.Padding = new System.Windows.Forms.Padding(0, 0, 0, 1);
    //this.radGridView1.MasterTemplate.AllowAddNewRow = false;
    //this.radGridView1.RootElement.Padding = new System.Windows.Forms.Padding(0, 0, 0, 1);

    hope that helps
    Richard

  14. AaronP
    AaronP avatar
    26 posts
    Member since:
    Apr 2010

    Posted 27 Jan 2011 Link to this post

    I commented out the lines on my test application and it worked, but when I tried the same thing on my main application it still crashes when AutoSizeRows = true.

    So I'm not quite sure what is going on, but it sounds like a Telerik bug.  You mentioned there is a AutoSizeRow issue already, do you happen to know what it is?

    Thank you again for your help,
    Aaron
  15. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 27 Jan 2011 Link to this post

    Hello,

    I've looked at the two issues in PITS
    http://www.telerik.com/support/pits.aspx#/public/winforms/2591
    http://www.telerik.com/support/pits.aspx#/public/winforms/4674

    and they don't seem to be relevant to your case. but if you'd like to post your application code as an extract here then I will gladly look at it. In the meantime, this may be a case for opening a new support ticket. Telerik can sign an NDA if required when you send them your real application for investigation.

    Let me know if there's anything else I can so
    Richard
  16. AaronP
    AaronP avatar
    26 posts
    Member since:
    Apr 2010

    Posted 27 Jan 2011 Link to this post

    I opened ticket 388705 with the my sample code attached. 
    For now, I'm going to just set AutoSizeRows = false since I really only had it set due to the header row having wrapped text. 
    I'm just going to set the Header height manually like:

    this.radGridView1.MasterGridViewInfo.TableHeaderRow.Height = 55;

    Thank you for your help and I'll see what support has to say.
    Aaron
  17. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 27 Jan 2011 Link to this post

    No problem. Glad to be able to help. If you get the time, I'd be interested to know the issue.
    Thanks
    Richard
  18. Answer
    Alexander
    Admin
    Alexander avatar
    306 posts

    Posted 28 Jan 2011 Link to this post

    Hello,

    Aaron, thank you for reporting this issue and sending a sample project in the support ticket. It is an issue in the layout system of RadGridView. I have added it to our PITS. We will address it in a next release.

    You can work around the issue by using the CellBeginEdit and CellEditorInitialized event of RadGridView to suspend the layout of the edited cell:
    this.radGridView1.CellBeginEdit += new GridViewCellCancelEventHandler(radGridView1_CellBeginEdit);
    this.radGridView1.CellEditorInitialized += new GridViewCellEventHandler(radGridView1_CellEditorInitialized);
     
    private void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
    {
        this.radGridView1.CurrentCell.SuspendLayout();
    }
     
    private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
    {
        this.radGridView1.CurrentCell.ResumeLayout(false);
        this.radGridView1.CurrentCell.InvalidateArrange(true);
    }

    Richard, I have updated your Telerik points for the community efforts.

    Best regards,
    Alexander
    the Telerik team
    Q3’10 SP1 of RadControls for WinForms is available for download; also available is the Q1'11 Roadmap for Telerik Windows Forms controls.
  19. AaronP
    AaronP avatar
    26 posts
    Member since:
    Apr 2010

    Posted 28 Jan 2011 Link to this post

    Thank you for the workaround and look forward to the next version.
    Aaron
  20. Michael
    Michael avatar
    47 posts
    Member since:
    Oct 2010

    Posted 11 Feb 2017 Link to this post

    Hi,

    I think this bug has been re-introduced.  I am using latest version 2017.1.117.40. When in Visual Studio 2015 and 2017, when I set property AutoSizeRows to true, VS freezes up and I have to kill the process.  I tried setting it through backend radGridView1.AutoSizeRows = true, then my program crashes as soon as the form with the grid opens up.

    Exception: System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'

    Inner Exception: KeyNotFoundException: The given key was not present in the dictionary.

    FYI,  I am using a RadGridView with column groups.  Some columns are stacked in 2 rows, other are not.  I hide the group column header and I have one template.

    Tried the workaround above, it did not help.

     

  21. Dimitar
    Admin
    Dimitar avatar
    2951 posts

    Posted 13 Feb 2017 Link to this post

    Hi Michael,

    You cannot use the AutoSizeRows functionality with the columns groups. It is only supported with the default TableViewDefinition.

    I hope this information helps.

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  22. Michael
    Michael avatar
    47 posts
    Member since:
    Oct 2010

    Posted 13 Feb 2017 in reply to Dimitar Link to this post

    Hi,

    Thanks for the reply. 

    Just a note, if this option cannot work, VS should not be crashing when you set this property through Properties window.  If this property is set through code behind, you should also give a meaningful exception stating the reason.

    Maybe you can put a feature request for this AutoSizeRows to work with the column groups? I think this is something other can benefit as well.

  23. Dimitar
    Admin
    Dimitar avatar
    2951 posts

    Posted 14 Feb 2017 Link to this post

    Hello Michael,

    You are correct and we already have a feature request for this. I have added a vote for it on your behalf. You can track its progress, subscribe for status changes and add your comment to it here

    Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  24. Dimitar
    Admin
    Dimitar avatar
    2951 posts

    Posted 15 Feb 2017 Link to this post

    Hello Michael,

    I have further discussed this with the team and it appears that this should work fine with the latest version of the suite. This is why I want to kindly ask you to open a support ticket and attach the code of your form. This will allow us to properly investigate the case and determine what is causing the exception.

    Thank you in advance for your patience and cooperation. 

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top