
KARTHIK REDDY KAMIDI
Top achievements
Rank 1
KARTHIK REDDY KAMIDI
asked on 23 Feb 2011, 08:43 PM
Hello,
I have a hierarchical GridView with about 250+ rows. Scrolling through the grid page at a time by clicking on the scrollbar throws exception.
Object reference not set to an instance of an object.
at Telerik.WinControls.UI.GridTraverser.StepInHierarchyBackward()
at Telerik.WinControls.UI.GridTraverser.MovePreviousCore()
at Telerik.WinControls.UI.GridTraverser.MovePrevious()
at Telerik.WinControls.UI.ItemScroller`1.ScrollUp(Int32 step)
at Telerik.WinControls.UI.ItemScroller`1.thumbTimer_Tick(Object sender, EventArgs e)
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.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 GridSample1.Program.Main() in C:\Users\MyUserName\Documents\GridSample1\Program.cs:line 18
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()
My code was working fine until Q2 2010 SP1. My current version is Q3 2010.
Thanks.
I have a hierarchical GridView with about 250+ rows. Scrolling through the grid page at a time by clicking on the scrollbar throws exception.
Object reference not set to an instance of an object.
at Telerik.WinControls.UI.GridTraverser.StepInHierarchyBackward()
at Telerik.WinControls.UI.GridTraverser.MovePreviousCore()
at Telerik.WinControls.UI.GridTraverser.MovePrevious()
at Telerik.WinControls.UI.ItemScroller`1.ScrollUp(Int32 step)
at Telerik.WinControls.UI.ItemScroller`1.thumbTimer_Tick(Object sender, EventArgs e)
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.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 GridSample1.Program.Main() in C:\Users\MyUserName\Documents\GridSample1\Program.cs:line 18
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()
My code was working fine until Q2 2010 SP1. My current version is Q3 2010.
Thanks.
17 Answers, 1 is accepted
0

Richard Slade
Top achievements
Rank 2
answered on 23 Feb 2011, 10:06 PM
Hello again,
I haven't been able to replicate this. Please could you put together a sample that replicates the issue (designer and form) and post the code here using the Format Code block and I'll see if I can replicate it too for you.
Thanks
Richard
I haven't been able to replicate this. Please could you put together a sample that replicates the issue (designer and form) and post the code here using the Format Code block and I'll see if I can replicate it too for you.
Thanks
Richard
0

Richard Slade
Top achievements
Rank 2
answered on 23 Feb 2011, 10:09 PM
Hi,
For reference, I've also looked in PITS and there were no reported issues of this nature at the moment.
Regards,
Richard
For reference, I've also looked in PITS and there were no reported issues of this nature at the moment.
Regards,
Richard
0

KARTHIK REDDY KAMIDI
Top achievements
Rank 1
answered on 24 Feb 2011, 11:32 PM
Richard,
Thank you again for looking into another one of my issues. My sample project is also included. The exceptions I get are as follows:
Clicking to scroll:
---------------------------
System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.WinControls.UI.GridTraverser.StepInHierarchyBackward()
at Telerik.WinControls.UI.GridTraverser.MovePreviousCore()
at Telerik.WinControls.UI.GridTraverser.MovePrevious()
at Telerik.WinControls.UI.ItemScroller`1.ScrollUp(Int32 step)
at Telerik.WinControls.UI.ItemScroller`1.thumbTimer_Tick(Object sender, EventArgs e)
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Dragging the scrollbar:
---------------------------
System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.WinControls.UI.GridTraverser.StepInHierarchyBackward()
at Telerik.WinControls.UI.GridTraverser.MovePreviousCore()
at Telerik.WinControls.UI.GridTraverser.MovePrevious()
at Telerik.WinControls.UI.ItemScroller`1.ScrollUp(Int32 step)
at Telerik.WinControls.UI.ItemScroller`1.UpdateOnScroll(ScrollEventArgs e)
at Telerik.WinControls.UI.ItemScroller`1.scrollbar_Scroll(Object sender, ScrollEventArgs e)
at Telerik.WinControls.UI.RadScrollBarElement.OnScroll(ScrollEventArgs args)
at Telerik.WinControls.UI.RadScrollBarElement.CallOnScroll(ScrollEventType scrollType, Int32 oldValue, Int32 newValue)
at Telerik.WinControls.UI.RadScrollBarElement.ScrollWith(Int32 step, ScrollEventType scrollType)
at Telerik.WinControls.UI.RadScrollBarElement.OnScrollTimer(Object sender, EventArgs e)
at Telerik.WinControls.UI.RadScrollBarElement.OnMouseDown(MouseEventArgs e)
at Telerik.WinControls.RadElement.OnCLREventsRise(RoutedEventArgs args)
at Telerik.WinControls.RadElement.OnBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadItem.OnBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.DoMouseDown(MouseEventArgs e)
at Telerik.WinControls.RadElement.CallDoMouseDown(MouseEventArgs e)
at Telerik.WinControls.ComponentInputBehavior.OnMouseDown(MouseEventArgs e)
at Telerik.WinControls.RadControl.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 Telerik.WinControls.RadControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Thanks.
Thank you again for looking into another one of my issues. My sample project is also included. The exceptions I get are as follows:
Clicking to scroll:
---------------------------
System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.WinControls.UI.GridTraverser.StepInHierarchyBackward()
at Telerik.WinControls.UI.GridTraverser.MovePreviousCore()
at Telerik.WinControls.UI.GridTraverser.MovePrevious()
at Telerik.WinControls.UI.ItemScroller`1.ScrollUp(Int32 step)
at Telerik.WinControls.UI.ItemScroller`1.thumbTimer_Tick(Object sender, EventArgs e)
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Dragging the scrollbar:
---------------------------
System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.WinControls.UI.GridTraverser.StepInHierarchyBackward()
at Telerik.WinControls.UI.GridTraverser.MovePreviousCore()
at Telerik.WinControls.UI.GridTraverser.MovePrevious()
at Telerik.WinControls.UI.ItemScroller`1.ScrollUp(Int32 step)
at Telerik.WinControls.UI.ItemScroller`1.UpdateOnScroll(ScrollEventArgs e)
at Telerik.WinControls.UI.ItemScroller`1.scrollbar_Scroll(Object sender, ScrollEventArgs e)
at Telerik.WinControls.UI.RadScrollBarElement.OnScroll(ScrollEventArgs args)
at Telerik.WinControls.UI.RadScrollBarElement.CallOnScroll(ScrollEventType scrollType, Int32 oldValue, Int32 newValue)
at Telerik.WinControls.UI.RadScrollBarElement.ScrollWith(Int32 step, ScrollEventType scrollType)
at Telerik.WinControls.UI.RadScrollBarElement.OnScrollTimer(Object sender, EventArgs e)
at Telerik.WinControls.UI.RadScrollBarElement.OnMouseDown(MouseEventArgs e)
at Telerik.WinControls.RadElement.OnCLREventsRise(RoutedEventArgs args)
at Telerik.WinControls.RadElement.OnBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadItem.OnBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.DoMouseDown(MouseEventArgs e)
at Telerik.WinControls.RadElement.CallDoMouseDown(MouseEventArgs e)
at Telerik.WinControls.ComponentInputBehavior.OnMouseDown(MouseEventArgs e)
at Telerik.WinControls.RadControl.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 Telerik.WinControls.RadControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Windows.Forms;
namespace
GridSample1
{
static
class
Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static
void
Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(
false
);
Application.ThreadException +=
new
System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
AppDomain.CurrentDomain.UnhandledException +=
new
UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.Run(
new
Form1());
}
static
void
CurrentDomain_UnhandledException(
object
sender, UnhandledExceptionEventArgs e)
{
MessageBox.Show(e.ExceptionObject.ToString());
}
static
void
Application_ThreadException(
object
sender, System.Threading.ThreadExceptionEventArgs e)
{
MessageBox.Show(e.Exception.ToString());
}
}
}
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;
namespace
GridSample1
{
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void
Form1_Load(
object
sender, EventArgs e)
{
this
.propertiesControl1.LoadVariables();
}
}
}
namespace
GridSample1
{
partial
class
Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private
System.ComponentModel.IContainer components =
null
;
/// <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
.propertiesControl1 =
new
GridSample1.PropertiesControl();
this
.SuspendLayout();
//
// propertiesControl1
//
this
.propertiesControl1.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
.propertiesControl1.Location =
new
System.Drawing.Point(13, 13);
this
.propertiesControl1.Name =
"propertiesControl1"
;
this
.propertiesControl1.Size =
new
System.Drawing.Size(532, 475);
this
.propertiesControl1.TabIndex = 0;
//
// Form1
//
this
.AutoScaleDimensions =
new
System.Drawing.SizeF(6F, 13F);
this
.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this
.ClientSize =
new
System.Drawing.Size(557, 500);
this
.Controls.Add(
this
.propertiesControl1);
this
.Name =
"Form1"
;
this
.Text =
"Form1"
;
this
.Load +=
new
System.EventHandler(
this
.Form1_Load);
this
.ResumeLayout(
false
);
}
#endregion
private
PropertiesControl propertiesControl1;
}
}
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
GridSample1
{
public
class
Model
{
public
Model() { }
public
Model(
string
id,
string
parentId,
string
name,
string
value,
string
units)
{
this
.Id = id;
this
.ParentId = parentId;
this
.Name = name;
this
.Value = value;
this
.Units = units; }
public
string
Id
{
get
;
set
; }
public
string
ParentId
{
get
;
set
; }
public
string
Name
{
get
;
set
; }
public
string
Value
{
get
;
set
; }
public
string
Units
{
get
;
set
; }
public
static
List<Model> GetDummyModelList()
{
var list =
new
List<Model>
{
new
Model(
"885"
,
"G63"
,
"Item 2"
,
"Value 2"
,
""
),
new
Model(
"900"
,
"G63"
,
"Item 3"
,
"Value 3"
,
""
),
new
Model(
"903"
,
"G63"
,
"Item 4"
,
"Value 4"
,
""
),
new
Model(
"886"
,
"G63"
,
"Item 5"
,
"Value 5"
,
"Unit 5"
),
new
Model(
"896"
,
"G63"
,
"Item 6"
,
"Value 6"
,
""
),
new
Model(
"897"
,
"G63"
,
"Item 7"
,
"Value 7"
,
""
),
new
Model(
"901"
,
"G63"
,
"Item 8"
,
"Value 8"
,
""
),
new
Model(
"902"
,
"G63"
,
"Item 9"
,
"Value 9"
,
""
),
new
Model(
"890"
,
"G63"
,
"Item 10"
,
"Value 10"
,
""
),
new
Model(
"893"
,
"G63"
,
"Item 11"
,
"Value 11"
,
""
),
new
Model(
"913"
,
"G63"
,
"Item 12"
,
"Value 12"
,
"Unit 12"
),
new
Model(
"914"
,
"G63"
,
"Item 13"
,
"Value 13"
,
"Unit 13"
),
new
Model(
"895"
,
"G63"
,
"Item 14"
,
"Value 14"
,
"Unit 14"
),
new
Model(
"892"
,
"G63"
,
"Item 15"
,
"Value 15"
,
"Unit 15"
),
new
Model(
"894"
,
"G63"
,
"Item 16"
,
"Value 16"
,
""
),
new
Model(
"891"
,
"G63"
,
"Item 17"
,
"Value 17"
,
"Unit 17"
),
new
Model(
"898"
,
"G63"
,
"Item 18"
,
"Value 18"
,
""
),
new
Model(
"889"
,
"G63"
,
"Item 19"
,
"Value 19"
,
"Unit 19"
),
new
Model(
"887"
,
"G63"
,
"Item 20"
,
"Value 20"
,
"Unit 20"
),
new
Model(
"888"
,
"G63"
,
"Item 21"
,
"Value 21"
,
"Unit 21"
),
new
Model(
"904"
,
"G63"
,
"Item 22"
,
"Value 22"
,
""
),
new
Model(
"907"
,
"G63"
,
"Item 23"
,
"Value 23"
,
""
),
new
Model(
"915"
,
"G63"
,
"Item 24"
,
"Value 24"
,
""
),
new
Model(
"908"
,
"G63"
,
"Item 25"
,
"Value 25"
,
""
),
new
Model(
"911"
,
"G63"
,
"Item 26"
,
"Value 26"
,
""
),
new
Model(
"906"
,
"G63"
,
"Item 27"
,
"Value 27"
,
""
),
new
Model(
"909"
,
"G63"
,
"Item 28"
,
"Value 28"
,
""
),
new
Model(
"910"
,
"G63"
,
"Item 29"
,
"Value 29"
,
""
),
new
Model(
"899"
,
"G63"
,
"Item 30"
,
"Value 30"
,
""
),
new
Model(
"912"
,
"G63"
,
"Item 31"
,
"Value 31"
,
""
),
new
Model(
"905"
,
"G63"
,
"Item 32"
,
"Value 32"
,
""
),
new
Model(
"G63"
,
""
,
"Group 1"
,
""
,
""
),
new
Model(
"925"
,
"G364"
,
"Item 33"
,
"Value 33"
,
""
),
new
Model(
"926"
,
"G364"
,
"Item 34"
,
"Value 34"
,
""
),
new
Model(
"G364"
,
""
,
"Group 2"
,
""
,
""
)
};
return
list;
}
}
}
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Drawing;
using
System.Data;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
using
Telerik.WinControls.UI;
using
System.Diagnostics;
namespace
GridSample1
{
public
partial
class
PropertiesControl : UserControl
{
Stopwatch stopwatch =
new
Stopwatch();
public
PropertiesControl()
{
InitializeComponent();
stopwatch.Start();
SetupRadGridviewRelation();
}
private
void
SetupRadGridviewRelation()
{
GridViewRelation selfRelation =
new
GridViewRelation(
this
.radGridView1.MasterTemplate,
this
.radGridView1.MasterTemplate);
selfRelation.ParentColumnNames.Add(
"IdCol"
);
selfRelation.ChildColumnNames.Add(
"ParentIdCol"
);
this
.radGridView1.Relations.Add(selfRelation);
}
public
void
LoadVariables()
{
var mboxCount = 0;
var list = Model.GetDummyModelList();
using
(
this
.radGridView1.DeferRefresh())
{
radGridView1.Rows.Clear();
foreach
(var item
in
list)
{
var rowNum = radGridView1.Rows.Add(item.Id, item.ParentId, item.Name, item.Value, item.Units);
if
(rowNum < 0)
++mboxCount;
else
radGridView1.Rows[rowNum].Tag = item;
}
}
ExpandRows();
if
(mboxCount > 0)
MessageBox.Show(
"Row num was -ve for "
+ mboxCount +
" rows, out of "
+ list.Count);
else
MessageBox.Show(
"Added "
+ list.Count +
" rows"
);
stopwatch.Stop();
}
private
void
ExpandRows()
{
using
(
this
.radGridView1.DeferRefresh())
{
foreach
(var childRow
in
radGridView1.ChildRows)
{
childRow.IsExpanded =
true
;
foreach
(var childChildRow
in
childRow.ChildRows)
{
childChildRow.IsExpanded =
true
;
foreach
(var childChildChildRow
in
childChildRow.ChildRows)
{
childChildChildRow.IsExpanded =
true
;
}
}
}
}
}
}
}
namespace
GridSample1
{
partial
class
PropertiesControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private
System.ComponentModel.IContainer components =
null
;
/// <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 Component 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()
{
Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn1 =
new
Telerik.WinControls.UI.GridViewTextBoxColumn();
Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn2 =
new
Telerik.WinControls.UI.GridViewTextBoxColumn();
Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn3 =
new
Telerik.WinControls.UI.GridViewTextBoxColumn();
Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn4 =
new
Telerik.WinControls.UI.GridViewTextBoxColumn();
Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn5 =
new
Telerik.WinControls.UI.GridViewTextBoxColumn();
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.MasterTemplate.AllowAddNewRow =
false
;
this
.radGridView1.MasterTemplate.AllowColumnChooser =
false
;
this
.radGridView1.MasterTemplate.AllowColumnReorder =
false
;
this
.radGridView1.MasterTemplate.AllowDeleteRow =
false
;
this
.radGridView1.MasterTemplate.AllowDragToGroup =
false
;
this
.radGridView1.MasterTemplate.AllowRowResize =
false
;
this
.radGridView1.MasterTemplate.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
gridViewTextBoxColumn1.FieldName =
"Id"
;
gridViewTextBoxColumn1.HeaderText =
"ID"
;
gridViewTextBoxColumn1.IsVisible =
false
;
gridViewTextBoxColumn1.Name =
"IdCol"
;
gridViewTextBoxColumn1.Width = 37;
gridViewTextBoxColumn2.FieldName =
"ParentId"
;
gridViewTextBoxColumn2.HeaderText =
"ParentID"
;
gridViewTextBoxColumn2.IsVisible =
false
;
gridViewTextBoxColumn2.Name =
"ParentIdCol"
;
gridViewTextBoxColumn2.Width = 48;
gridViewTextBoxColumn3.FieldName =
"VarName"
;
gridViewTextBoxColumn3.HeaderText =
"Name"
;
gridViewTextBoxColumn3.Name =
"NameCol"
;
gridViewTextBoxColumn3.Width = 255;
gridViewTextBoxColumn4.FieldName =
"VarValue"
;
gridViewTextBoxColumn4.HeaderText =
"Value"
;
gridViewTextBoxColumn4.Name =
"ValueCol"
;
gridViewTextBoxColumn4.Width = 78;
gridViewTextBoxColumn5.FieldName =
"VarUnits"
;
gridViewTextBoxColumn5.HeaderText =
"Units"
;
gridViewTextBoxColumn5.Name =
"UnitsCol"
;
gridViewTextBoxColumn5.Width = 57;
this
.radGridView1.MasterTemplate.Columns.AddRange(
new
Telerik.WinControls.UI.GridViewDataColumn[] {
gridViewTextBoxColumn1,
gridViewTextBoxColumn2,
gridViewTextBoxColumn3,
gridViewTextBoxColumn4,
gridViewTextBoxColumn5});
this
.radGridView1.MasterTemplate.EnableGrouping =
false
;
this
.radGridView1.MasterTemplate.EnableSorting =
false
;
this
.radGridView1.MasterTemplate.ShowRowHeaderColumn =
false
;
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.ShowGroupPanel =
false
;
this
.radGridView1.ShowRowErrors =
false
;
this
.radGridView1.Size =
new
System.Drawing.Size(465, 465);
this
.radGridView1.TabIndex = 0;
this
.radGridView1.Text =
"radGridView1"
;
//
// PropertiesControl
//
this
.AutoScaleDimensions =
new
System.Drawing.SizeF(6F, 13F);
this
.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this
.Controls.Add(
this
.radGridView1);
this
.Name =
"PropertiesControl"
;
this
.Size =
new
System.Drawing.Size(465, 465);
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1)).EndInit();
this
.ResumeLayout(
false
);
}
#endregion
private
Telerik.WinControls.UI.RadGridView radGridView1;
}
}
Thanks.
0
Accepted

Richard Slade
Top achievements
Rank 2
answered on 25 Feb 2011, 01:31 AM
Hello,
The issue here is with the expand. In your code you are drilling down to try and expand for more levels than you actually have. In the case of the sample that you have given your expand code should be modified as follows:
However, even though you're not using it, the HasChildRows() method returns true even though the ChildRows.Count = 0.
I beleive Telerik need to look at this one to confirm that this [may be] is an issue. For the moment however, you should just drill down your expand for the number of levels that you expect in your hierarchy.
I hope that this is helpful but please let me know if I can help further
Richard
The issue here is with the expand. In your code you are drilling down to try and expand for more levels than you actually have. In the case of the sample that you have given your expand code should be modified as follows:
private
void
ExpandRows()
{
using
(
this
.radGridView1.DeferRefresh())
{
foreach
(var childRow
in
radGridView1.ChildRows)
{
childRow.IsExpanded =
true
;
//foreach (var childChildRow in childRow.ChildRows)
//{
// childChildRow.IsExpanded = true;
// foreach (var childChildChildRow in childChildRow.ChildRows)
// {
// //childChildChildRow.IsExpanded = true;
// }
//}
}
}
}
However, even though you're not using it, the HasChildRows() method returns true even though the ChildRows.Count = 0.
I beleive Telerik need to look at this one to confirm that this [may be] is an issue. For the moment however, you should just drill down your expand for the number of levels that you expect in your hierarchy.
I hope that this is helpful but please let me know if I can help further
Richard
0

Richard Slade
Top achievements
Rank 2
answered on 28 Feb 2011, 12:20 PM
Hello,
If you found this helpful, please remember to mark as answer. If you need further assistance, please let me know
Thanks
Richard
If you found this helpful, please remember to mark as answer. If you need further assistance, please let me know
Thanks
Richard
0

Emanuel Varga
Top achievements
Rank 1
answered on 28 Feb 2011, 02:55 PM
Hello KARTHIK REDDY KAMIDI, Richard,
I've submitted a bug report with this issue this morning, it is related to the self referencing hierarchy and if you expand all the rows programatically it crashes if you are scrolling UP the grid, down everything is ok, i've tried everything to get around this but nothing works.
As soon as i have an answer from telerik i will get back to you (hopefully with a good workaround)
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
I've submitted a bug report with this issue this morning, it is related to the self referencing hierarchy and if you expand all the rows programatically it crashes if you are scrolling UP the grid, down everything is ok, i've tried everything to get around this but nothing works.
As soon as i have an answer from telerik i will get back to you (hopefully with a good workaround)
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
0

Richard Slade
Top achievements
Rank 2
answered on 28 Feb 2011, 03:02 PM
Hi Emanuel,
Yes, I've been trying it too. Good that you have submitted a bug report.
I don't know if you have tried my sugestion, but that seems to work fine when expanding based on the sample that KARTHIK REDDY KAMIDI provided. However, the HasChildRows doesn't seem to be in sync with the true representation of whether the row has child rows.
Did you include the link to this forum post in your bug report? If not, it might be a good idea to do so, in order to keep a good track of all related material and incidents.
Let me know if you have any questions
Richard
Yes, I've been trying it too. Good that you have submitted a bug report.
I don't know if you have tried my sugestion, but that seems to work fine when expanding based on the sample that KARTHIK REDDY KAMIDI provided. However, the HasChildRows doesn't seem to be in sync with the true representation of whether the row has child rows.
Did you include the link to this forum post in your bug report? If not, it might be a good idea to do so, in order to keep a good track of all related material and incidents.
Let me know if you have any questions
Richard
0

Emanuel Varga
Top achievements
Rank 1
answered on 28 Feb 2011, 03:06 PM
Hello again Richard,
I've submitted it this morning with no relation whatsoever to this post, I've been trying to come up with a working solution to this and 2 other very annoying problems with the self referencing hierarchy:
Best Regards,
Emanuel Varga
Telerik WinForms MVP
I've submitted it this morning with no relation whatsoever to this post, I've been trying to come up with a working solution to this and 2 other very annoying problems with the self referencing hierarchy:
- You cannot set the datasource to null, it will crash (tried clearing relations and everything i could have tough of)
- Click the BestFit context menu option 2,3 times on the first cell header (the one with the hierarchy expand / collapse sign). Do you still see the expand collapse sign ?
Best Regards,
Emanuel Varga
Telerik WinForms MVP
0

Richard Slade
Top achievements
Rank 2
answered on 28 Feb 2011, 03:31 PM
Hi Emanuel,
I don't want to clutter up this forum thread, so we can continue off-line if you prefer, but I've been doing some investigstion into your findings.
I don't want to clutter up this forum thread, so we can continue off-line if you prefer, but I've been doing some investigstion into your findings.
- The BestFit issue also occurs if you double click the separator. The +- is still there, but you need to re-alter the column size manually in order to see it again.
- Setting the data source to null is only a problem if you have AutoGenerateColumns = true. If you have this set to false and specifiy the columns, then it's fine.
Speak soon
regards,
Richard
0

Richard Slade
Top achievements
Rank 2
answered on 28 Feb 2011, 03:51 PM
Hi Emanuel,
This will overcome the datasource issue when you have AutoGenerateColumns = true
Let me know if you have any questions
Richard
This will overcome the datasource issue when you have AutoGenerateColumns = true
Array columnsArray =
this
.radGridView1.Columns.ToArray();
foreach
(GridViewColumn col
in
columnsArray)
{
this
.radGridView1.Columns.Remove(col.Name);
}
this
.radGridView1.DataSource =
null
;
Let me know if you have any questions
Richard
0

Emanuel Varga
Top achievements
Rank 1
answered on 28 Feb 2011, 03:58 PM
Hello again Richard,
Why would you have to remove all the columns in order to set the datasource to null?
It's a bug on their side, honestly i would prefer not to have these kind of workarounds if by possible.
But please change that for to a reverse loop or use a foreach with a Columns.ToArray() to remove the columns.
I'll let you know as soon as i have an answer from telerik
Best Regards,
Emanuel Varga
Telerik WinForms MVP
Why would you have to remove all the columns in order to set the datasource to null?
It's a bug on their side, honestly i would prefer not to have these kind of workarounds if by possible.
But please change that for to a reverse loop or use a foreach with a Columns.ToArray() to remove the columns.
I'll let you know as soon as i have an answer from telerik
Best Regards,
Emanuel Varga
Telerik WinForms MVP
0

Richard Slade
Top achievements
Rank 2
answered on 28 Feb 2011, 04:05 PM
Hi Emanuel,
I'm agreeing that it is a bug. I'm providing a workaround to this issue.
I believe that this is related to the child rows issue as per the Grid Scolling issue as the error that is received on this leads back to the GetChildRows method.
Let me know if you have further comments
Richard
I'm agreeing that it is a bug. I'm providing a workaround to this issue.
I believe that this is related to the child rows issue as per the Grid Scolling issue as the error that is received on this leads back to the GetChildRows method.
Let me know if you have further comments
Richard
0

KARTHIK REDDY KAMIDI
Top achievements
Rank 1
answered on 28 Feb 2011, 05:38 PM
Richard,
Thank you very much for the workaround. I was desperately looking for a solution.
Thanks.
Thank you very much for the workaround. I was desperately looking for a solution.
Thanks.
0

KARTHIK REDDY KAMIDI
Top achievements
Rank 1
answered on 28 Feb 2011, 05:40 PM
Emanuel,
Thank you for looking into this issue and posting it as a bug. Hopefully Telerik will fix this as soon as possible.
Thanks.
Thank you for looking into this issue and posting it as a bug. Hopefully Telerik will fix this as soon as possible.
Thanks.
0

KARTHIK REDDY KAMIDI
Top achievements
Rank 1
answered on 28 Feb 2011, 08:45 PM
Hello,
I've run into another problem with the grid. After the user changes a value, I have to reevaluate all cells in the second column and reload their values.
The above code takes care of that. But the problem is that I have about 400 rows in the grid and after the ReloadVariables() method is called the grid scrolls to the top. That is the user is editing a cell somewhere in the 300th row and after editing and while trying to move to the next row, the grid automatically scrolls to the top.
If I do not user DeferRefresh() in the ReloadVariables(), the grid maintains its position, but I find that then the ReloadVariables() method is taking time.
Is there a workaround for this?
Thanks.
I've run into another problem with the grid. After the user changes a value, I have to reevaluate all cells in the second column and reload their values.
private
void
ReloadVariables()
{
using
(
this
.radGridView1.DeferRefresh())
{
foreach
(var row
in
radGridView1.Rows)
{
var varmodel = row.Tag
as
Model;
row.Cells[3].Value = varmodel.Value +
" (Upd)"
; // business logic goes here
}
}
}
void
radGridView1_RowValidated(
object
sender, RowValidatedEventArgs e)
{
ReloadVariables();
}
public
PropertiesControl()
{
InitializeComponent();
stopwatch.Start();
SetupRadGridviewRelation();
radGridView1.RowValidated +=
new
RowValidatedEventHandler(radGridView1_RowValidated);
}
The above code takes care of that. But the problem is that I have about 400 rows in the grid and after the ReloadVariables() method is called the grid scrolls to the top. That is the user is editing a cell somewhere in the 300th row and after editing and while trying to move to the next row, the grid automatically scrolls to the top.
If I do not user DeferRefresh() in the ReloadVariables(), the grid maintains its position, but I find that then the ReloadVariables() method is taking time.
Is there a workaround for this?
Thanks.
0

Emanuel Varga
Top achievements
Rank 1
answered on 01 Mar 2011, 10:01 AM
Hello again,
I have a different proposal for you, i know it's not the cleanest out there, but the row validated event will only fire after the user has changed the row, and it will fire every time the user changes a row, i would suggest you use the CellValueChanged event like so:
or in order to remember the position on the grid you can just save the values of the scrollbars in the ReloadVariables, like so;
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
I have a different proposal for you, i know it's not the cleanest out there, but the row validated event will only fire after the user has changed the row, and it will fire every time the user changes a row, i would suggest you use the CellValueChanged event like so:
void
radGridView1_CellValueChanged(
object
sender, GridViewCellEventArgs e)
{
if
(e.ColumnIndex == 1)
{
var timer =
new
Timer();
timer.Interval = 20;
timer.Tick +=
delegate
{
timer.Enabled =
false
;
ReloadVariables();
};
timer.Enabled =
true
;
}
}
or in order to remember the position on the grid you can just save the values of the scrollbars in the ReloadVariables, like so;
private
void
ReloadVariables()
{
var scrollPos = radGridView1.GridElement.VScrollBar.Value;
using
(radGridView1.DeferRefresh())
{
foreach
(var row
in
radGridView1.Rows)
{
var varmodel = row.Tag
as
Model;
row.Cells[3].Value = varmodel.Value +
" (Upd)"
;
// business logic goes here
}
}
radGridView1.GridElement.VScrollBar.Value = scrollPos;
}
Hope this helps, if you have any other questions or comments, please let me know,
Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Hi all,
@KARTHIK: Emanuel's suggestions sound reasonable and you should try them. I took a look at your sample and I am wondering why are you not using the grid in bound mode. Doing so will prevent you from bothering of updating items. Are you experiencing issues with the bound mode?
@Richard, Emanuel: Thank you guys for following up on this thread and reporting the issues encountered.
Regards,
@KARTHIK: Emanuel's suggestions sound reasonable and you should try them. I took a look at your sample and I am wondering why are you not using the grid in bound mode. Doing so will prevent you from bothering of updating items. Are you experiencing issues with the bound mode?
@Richard, Emanuel: Thank you guys for following up on this thread and reporting the issues encountered.
Regards,
Ivan Todorov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!