Hi,
When I create a simple hierarchical grid view (example code snippet (4) attached below) I'm getting an exception (2) with a stack trace (3) you can find below. t occurs always when there are 3 or more hierarchy levels. Below I'm describing also reproducibility steps.
Any patch or feedback if I''m doing anything wrong would be appreciated.
Regards.
Reproducibility Steps:
1. Use code snippet
2. Expand all nodes
3. Collapse first root node
1 Exception
ArgumentOutOfRangeException
{
"Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"
}
2 Stack trace
01.
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
02.
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
03.
at System.Collections.Generic.List`1.get_Item(Int32 index)
04.
at Telerik.WinControls.UI.PriorityWeakReferenceList.<ReverseForEach>d__0.MoveNext()
05.
at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessCollection(GridViewEvent gridEvent, PriorityWeakReferenceList list, GridEventProcessMode processMode)
06.
at Telerik.WinControls.UI.GridViewEventProcessEntity.ProcessEvent(GridViewEvent gridEvent)
07.
at Telerik.WinControls.UI.GridViewSynchronizationService.NotifyListeners(GridViewEvent gridEvent)
08.
at Telerik.WinControls.UI.GridViewSynchronizationService.FlushEvents()
09.
at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewEvent gridEvent)
10.
at Telerik.WinControls.UI.GridViewSynchronizationService.DispatchEvent(GridViewTemplate template, GridViewEvent eventData, Boolean postUI)
11.
at Telerik.WinControls.UI.GridViewRowInfo.DispatchEvent(Int32 id, GridEventType type, GridEventDispatchMode dispatchMode, Object originator, Object[] arguments)
12.
at Telerik.WinControls.UI.GridViewRowInfo.OnPropertyChanged(PropertyChangedEventArgs args)
13.
at Telerik.WinControls.UI.GridViewDataRowInfo.OnPropertyChanged(PropertyChangedEventArgs e)
14.
at Telerik.WinControls.UI.GridViewHierarchyRowInfo.OnPropertyChanged(PropertyChangedEventArgs e)
15.
at Telerik.WinControls.UI.GridViewRowInfo.SetBooleanProperty(String propertyName, Int32 propertyKey, Boolean value)
16.
at Telerik.WinControls.UI.GridViewRowInfo.set_IsExpanded(Boolean value)
17.
at Telerik.WinControls.UI.GridGroupExpanderCellElement.expander_RadPropertyChanged(Object sender, RadPropertyChangedEventArgs e)
18.
at Telerik.WinControls.RadPropertyChangedEventHandler.Invoke(Object sender, RadPropertyChangedEventArgs e)
19.
at Telerik.WinControls.RadObject.OnPropertyChanged(RadPropertyChangedEventArgs e)
20.
at Telerik.WinControls.RadElement.OnPropertyChanged(RadPropertyChangedEventArgs e)
21.
at Telerik.WinControls.VisualElement.OnPropertyChanged(RadPropertyChangedEventArgs e)
22.
at Telerik.WinControls.RadComponentElement.OnPropertyChanged(RadPropertyChangedEventArgs e)
23.
at Telerik.WinControls.RadItem.OnPropertyChanged(RadPropertyChangedEventArgs e)
24.
at Telerik.WinControls.UI.GridExpanderItem.OnPropertyChanged(RadPropertyChangedEventArgs e)
25.
at Telerik.WinControls.RadObject.RaisePropertyNotifications(RadPropertyValue propVal, Object oldValue, Object newValue, ValueSource oldSource)
26.
at Telerik.WinControls.RadObject.SetValueCore(RadPropertyValue propVal, Object propModifier, Object newValue, ValueSource source)
27.
at Telerik.WinControls.RadElement.SetValueCore(RadPropertyValue propVal, Object propModifier, Object newValue, ValueSource source)
28.
at Telerik.WinControls.RadObject.SetValue(RadProperty property, Object value)
29.
at Telerik.WinControls.UI.GridExpanderItem.set_Expanded(Boolean value)
30.
at Telerik.WinControls.UI.GridExpanderItem.OnMouseUp(MouseEventArgs e)
31.
at Telerik.WinControls.RadElement.OnCLREventsRise(RoutedEventArgs args)
32.
at Telerik.WinControls.RadElement.OnBubbleEvent(RadElement sender, RoutedEventArgs args)
33.
at Telerik.WinControls.RadItem.OnBubbleEvent(RadElement sender, RoutedEventArgs args)
34.
at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
35.
at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
36.
at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
37.
at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e)
38.
at Telerik.WinControls.RadElement.CallDoMouseUp(MouseEventArgs e)
39.
at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
40.
at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
41.
at Telerik.WinControls.UI.RadGridView.OnMouseUp(MouseEventArgs e)
42.
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
43.
at System.Windows.Forms.Control.WndProc(Message& m)
44.
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
45.
at Telerik.WinControls.RadControl.WndProc(Message& m)
46.
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
47.
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
48.
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
49.
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
50.
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
51.
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
52.
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
53.
at System.Windows.Forms.Application.Run(Form mainForm)
54.
at TelerikGrid.Program.Main()
in
C:\Users\mbandrowski\Desktop\proof\TelerikGrid\TelerikGrid\Program.cs:line 18
55.
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
56.
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
57.
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
58.
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
59.
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
60.
at System.Threading.ThreadHelper.ThreadStart()
3. Code snippet:
001.
using
System;
002.
using
System.Collections.Generic;
003.
using
System.ComponentModel;
004.
using
System.Data;
005.
using
System.Drawing;
006.
using
System.Linq;
007.
using
System.Text;
008.
using
System.Windows.Forms;
009.
using
Telerik.WinControls.UI;
010.
011.
namespace
TelerikGrid
012.
{
013.
014.
public
class
a
015.
{
016.
public
int
IdA
017.
{
018.
get
;
019.
set
;
020.
}
021.
022.
public
string
strPropertrya
023.
{
024.
get
;
025.
set
;
026.
}
027.
}
028.
029.
public
class
b
030.
{
031.
public
int
IdA
032.
{
033.
get
;
034.
set
;
035.
}
036.
037.
public
int
IdB
038.
{
039.
get
;
040.
set
;
041.
}
042.
043.
public
string
strPropertryb
044.
{
045.
get
;
046.
set
;
047.
}
048.
}
049.
050.
public
class
c
051.
{
052.
public
int
IdB
053.
{
054.
get
;
055.
set
;
056.
}
057.
058.
public
int
IdC
059.
{
060.
get
;
061.
set
;
062.
}
063.
064.
public
string
strPropertryc
065.
{
066.
get
;
067.
set
;
068.
}
069.
}
070.
071.
public
partial
class
Form1 : Form
072.
{
073.
BindingList<a> aList =
new
BindingList<a>();
074.
BindingList<b> bList =
new
BindingList<b>();
075.
BindingList<c> cList =
new
BindingList<c>();
076.
077.
public
Form1()
078.
{
079.
InitializeComponent();
080.
081.
aList.Add(
new
a() { IdA = 1, strPropertrya =
"asd"
});
082.
aList.Add(
new
a() { IdA = 2, strPropertrya =
"fsds"
});
083.
084.
bList.Add(
new
b() { IdA = 1, IdB = 1, strPropertryb =
"xcvxbd"
});
085.
bList.Add(
new
b() { IdA = 1, IdB = 2, strPropertryb =
"cbvasd"
});
086.
bList.Add(
new
b() { IdA = 2, IdB = 3, strPropertryb =
"x54xsd"
});
087.
bList.Add(
new
b() { IdA = 2, IdB = 4, strPropertryb =
"45fasd"
});
088.
089.
cList.Add(
new
c() { IdC = 1, IdB = 1, strPropertryc =
"12435d"
});
090.
cList.Add(
new
c() { IdC = 2, IdB = 1, strPropertryc =
"c34asd"
});
091.
cList.Add(
new
c() { IdC = 3, IdB = 2, strPropertryc =
"x234sd"
});
092.
cList.Add(
new
c() { IdC = 4, IdB = 2, strPropertryc =
"234asd"
});
093.
cList.Add(
new
c() { IdC = 5, IdB = 3, strPropertryc =
"x234bd"
});
094.
cList.Add(
new
c() { IdC = 6, IdB = 3, strPropertryc =
"5243sd"
});
095.
cList.Add(
new
c() { IdC = 7, IdB = 4, strPropertryc =
"x34234"
});
096.
cList.Add(
new
c() { IdC = 8, IdB = 4, strPropertryc =
"45324d"
});
097.
098.
abindingSource.DataSource = aList;
099.
bbindingSource.DataSource = bList;
100.
cbindingSource.DataSource = cList;
101.
102.
GridViewTemplate btempate =
new
GridViewTemplate();
103.
btempate.DataSource = bbindingSource;
104.
radGridView1.MasterTemplate.Templates.Add(btempate);
105.
106.
GridViewRelation brelation =
new
GridViewRelation(radGridView1.MasterTemplate);
107.
brelation.ChildTemplate = btempate;
108.
brelation.ChildColumnNames.Add(
"IdA"
);
109.
brelation.ParentColumnNames.Add(
"IdA"
);
110.
radGridView1.Relations.Add(brelation);
111.
112.
113.
GridViewTemplate ctemplate =
new
GridViewTemplate();
114.
ctemplate.DataSource = cbindingSource;
115.
btempate.Templates.Add(ctemplate);
116.
117.
GridViewRelation crelation =
new
GridViewRelation(btempate);
118.
crelation.ChildTemplate = ctemplate;
119.
crelation.ChildColumnNames.Add(
"IdB"
);
120.
crelation.ParentColumnNames.Add(
"IdB"
);
121.
radGridView1.Relations.Add(crelation);
122.
123.
124.
abindingSource.ResetBindings(
true
);
125.
bbindingSource.ResetBindings(
true
);
126.
cbindingSource.ResetBindings(
true
);
127.
128.
129.
radGridView1.EnableGrouping =
true
;
130.
radGridView1.MasterTemplate.EnableFiltering =
true
;
131.
radGridView1.MasterTemplate.ShowFilteringRow =
true
;
132.
radGridView1.ReadOnly =
true
;
133.
radGridView1.SelectionMode = GridViewSelectionMode.FullRowSelect;
134.
135.
136.
radGridView1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None;
137.
radGridView1.MasterTemplate.Templates[0].AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.None;
138.
radGridView1.MasterTemplate.EnableAlternatingRowColor =
true
;
139.
radGridView1.MasterTemplate.Templates[0].EnableAlternatingRowColor =
true
;
140.
}
141.
142.
143.
/// <summary>
144.
/// Required designer variable.
145.
/// </summary>
146.
private
System.ComponentModel.IContainer components =
null
;
147.
148.
/// <summary>
149.
/// Clean up any resources being used.
150.
/// </summary>
151.
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
152.
protected
override
void
Dispose(
bool
disposing)
153.
{
154.
if
(disposing && (components !=
null
))
155.
{
156.
components.Dispose();
157.
}
158.
base
.Dispose(disposing);
159.
}
160.
161.
#region Windows Form Designer generated code
162.
163.
/// <summary>
164.
/// Required method for Designer support - do not modify
165.
/// the contents of this method with the code editor.
166.
/// </summary>
167.
private
void
InitializeComponent()
168.
{
169.
this
.components =
new
System.ComponentModel.Container();
170.
Telerik.WinControls.UI.GridViewDecimalColumn gridViewDecimalColumn27 =
new
Telerik.WinControls.UI.GridViewDecimalColumn();
171.
Telerik.WinControls.UI.GridViewTextBoxColumn gridViewTextBoxColumn27 =
new
Telerik.WinControls.UI.GridViewTextBoxColumn();
172.
this
.radGridView1 =
new
Telerik.WinControls.UI.RadGridView();
173.
this
.abindingSource =
new
System.Windows.Forms.BindingSource(
this
.components);
174.
this
.bbindingSource =
new
System.Windows.Forms.BindingSource(
this
.components);
175.
this
.cbindingSource =
new
System.Windows.Forms.BindingSource(
this
.components);
176.
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1)).BeginInit();
177.
((System.ComponentModel.ISupportInitialize)(
this
.abindingSource)).BeginInit();
178.
((System.ComponentModel.ISupportInitialize)(
this
.bbindingSource)).BeginInit();
179.
((System.ComponentModel.ISupportInitialize)(
this
.cbindingSource)).BeginInit();
180.
this
.SuspendLayout();
181.
//
182.
// radGridView1
183.
//
184.
this
.radGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
185.
this
.radGridView1.Location =
new
System.Drawing.Point(0, 0);
186.
//
187.
// radGridView1
188.
//
189.
gridViewDecimalColumn27.DataType =
typeof
(
int
);
190.
gridViewDecimalColumn27.FieldName =
"IdA"
;
191.
gridViewDecimalColumn27.HeaderText =
"IdA"
;
192.
gridViewDecimalColumn27.IsAutoGenerated =
true
;
193.
gridViewDecimalColumn27.Name =
"IdA"
;
194.
gridViewDecimalColumn27.TextAlignment = System.Drawing.ContentAlignment.MiddleRight;
195.
gridViewTextBoxColumn27.FieldName =
"strPropertrya"
;
196.
gridViewTextBoxColumn27.HeaderText =
"strPropertrya"
;
197.
gridViewTextBoxColumn27.IsAutoGenerated =
true
;
198.
gridViewTextBoxColumn27.Name =
"strPropertrya"
;
199.
this
.radGridView1.MasterTemplate.Columns.AddRange(
new
Telerik.WinControls.UI.GridViewDataColumn[] {
200.
gridViewDecimalColumn27,
201.
gridViewTextBoxColumn27});
202.
this
.radGridView1.MasterTemplate.DataSource =
this
.abindingSource;
203.
this
.radGridView1.Name =
"radGridView1"
;
204.
this
.radGridView1.Padding =
new
System.Windows.Forms.Padding(0, 0, 0, 1);
205.
this
.radGridView1.Size =
new
System.Drawing.Size(478, 415);
206.
this
.radGridView1.TabIndex = 0;
207.
this
.radGridView1.Text =
"radGridView1"
;
208.
//
209.
// abindingSource
210.
//
211.
this
.abindingSource.DataSource =
typeof
(a);
212.
//
213.
// bbindingSource
214.
//
215.
this
.bbindingSource.DataSource =
typeof
(b);
216.
//
217.
// cbindingSource
218.
//
219.
this
.cbindingSource.DataSource =
typeof
(c);
220.
//
221.
// Form1
222.
//
223.
this
.AutoScaleDimensions =
new
System.Drawing.SizeF(6F, 13F);
224.
this
.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
225.
this
.ClientSize =
new
System.Drawing.Size(478, 415);
226.
this
.Controls.Add(
this
.radGridView1);
227.
this
.Name =
"Form1"
;
228.
this
.Text =
"Form1"
;
229.
((System.ComponentModel.ISupportInitialize)(
this
.radGridView1)).EndInit();
230.
((System.ComponentModel.ISupportInitialize)(
this
.abindingSource)).EndInit();
231.
((System.ComponentModel.ISupportInitialize)(
this
.bbindingSource)).EndInit();
232.
((System.ComponentModel.ISupportInitialize)(
this
.cbindingSource)).EndInit();
233.
this
.ResumeLayout(
false
);
234.
235.
}
236.
237.
#endregion
238.
239.
private
Telerik.WinControls.UI.RadGridView radGridView1;
240.
private
System.Windows.Forms.BindingSource abindingSource;
241.
private
System.Windows.Forms.BindingSource bbindingSource;
242.
private
System.Windows.Forms.BindingSource cbindingSource;
243.
}
244.
}