Please refer to the attached sample project. After running it, the following error is observed:
************** Exception Text ************** System.NullReferenceException: Object reference not set to an instance of an object. at Telerik.WinControls.UI.RadPictureBoxElement.UpdateParentControl() at Telerik.WinControls.UI.RadPictureBoxElement.OnParentChanged(RadElement previousParent) at Telerik.WinControls.RadElement.SetParent(RadElement parent) at Telerik.WinControls.RadElement.ChangeCollection(RadElement child, ItemsChangeOperation changeOperation) at Telerik.WinControls.RadElementCollection.OnInsertComplete(Int32 index, Object value) at System.Collections.CollectionBase.System.Collections.IList.Add(Object value) at Telerik.WinControls.RadElementCollection.Add(RadElement value) at _1574930GanttCustomDataItem.RadForm1.customGanttViewTextViewCellElement.CreateChildElements() in C:\Projects\1574930GanttCustomDataItem\1574930GanttCustomDataItem\RadForm1.vb:line 75 at Telerik.WinControls.RadElement.CallCreateChildElements() at Telerik.WinControls.RadElement.Construct() at Telerik.WinControls.RadElement..ctor() at Telerik.WinControls.RadItem..ctor() at Telerik.WinControls.UI.GanttViewTextViewCellElement..ctor(GanttViewTextItemElement owner, GanttViewTextViewColumn column) at _1574930GanttCustomDataItem.RadForm1.customGanttViewTextViewCellElement..ctor(GanttViewTextItemElement owner, GanttViewTextViewColumn column) in C:\Projects\1574930GanttCustomDataItem\1574930GanttCustomDataItem\RadForm1.vb:line 59 at _1574930GanttCustomDataItem.RadForm1.radGanttView1_DataCellElementCreating(Object sender, GanttViewDataCellElementCreatingEventArgs e) in C:\Projects\1574930GanttCustomDataItem\1574930GanttCustomDataItem\RadForm1.vb:line 51 at Telerik.WinControls.UI.RadGanttViewElement.OnDataCellCreating(GanttViewDataCellElementCreatingEventArgs e) at Telerik.WinControls.UI.GanttViewTextViewCellElementProvider.CreateElement(GanttViewTextViewColumn data, Object context) at Telerik.WinControls.UI.BaseVirtualizedElementProvider`1.GetElement(T data, Object context) at Telerik.WinControls.UI.BaseVirtualizedContainer`1.UpdateElement(Int32 position, T data) at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureElements() at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureOverride(SizeF availableSize) at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize) at Telerik.WinControls.RadElement.Measure(SizeF availableSize) at Telerik.WinControls.UI.LightVisualElement.MeasureElements(SizeF availableSize, SizeF clientSize, Padding borderThickness) at Telerik.WinControls.UI.LightVisualElement.MeasureOverride(SizeF availableSize) at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize) at Telerik.WinControls.RadElement.Measure(SizeF availableSize) at Telerik.WinControls.UI.VirtualizedStackContainer`1.MeasureElementCore(RadElement element, SizeF availableSize) at Telerik.WinControls.UI.VirtualizedStackContainer`1.MeasureElement(IVirtualizedElement`1 element) at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureElements() at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureOverride(SizeF availableSize) at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize) at Telerik.WinControls.RadElement.Measure(SizeF availableSize) at Telerik.WinControls.UI.GanttViewTextViewElement.MeasureOverride(SizeF availableSize) at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize) at Telerik.WinControls.RadElement.Measure(SizeF availableSize) at Telerik.WinControls.UI.RadGanttViewElement.MeasureOverride(SizeF availableSize) at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize) at Telerik.WinControls.RadElement.Measure(SizeF availableSize) at Telerik.WinControls.RootRadElement.MeasureOverride(SizeF availableSize) at Telerik.WinControls.RootRadElement.MeasureCore(SizeF availableSize) at Telerik.WinControls.RadElement.Measure(SizeF availableSize) at Telerik.WinControls.RadElementTree.PerformInnerLayout(Boolean performMeasure, Int32 x, Int32 y, Int32 width, Int32 height) at Telerik.WinControls.RadControl.OnLoad(Size desiredSize) at Telerik.WinControls.RadControl.LoadElementTree(Size desiredSize) at Telerik.WinControls.RadControl.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at Telerik.WinControls.UI.RadFormControlBase.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) ************** Loaded Assemblies **************
Workaround: set the RadOictureBoxElement.PanelDisplayMode property to PictureBoxPanelDisplayMode.None.
Please use the following code snippet:
public partial class Form1 : Form
{
public class VM
{
public string Text
{
get; set;
}
public DateTime Start
{
get; set;
}
public DateTime End
{
get; set;
}
}
public Form1()
{
InitializeComponent();
var ViewModel = new VM[]
{
new VM()
{
Text = "CrashTest",
Start = new DateTime(2021, 11, 3, 10, 0, 0),
End = new DateTime( 2021, 11, 3, 23, 0, 0 ) //crash
//End = new DateTime( 2021, 11, 3, 22, 0, 0 ) //No crash
},
};
radGanttView1.GanttViewElement.GraphicalViewElement.OnePixelTime = new TimeSpan( 0, 1, 0 );
radGanttView1.GanttViewElement.GraphicalViewElement.TimelineStart = ViewModel.Min( T => T.Start );
radGanttView1.GanttViewElement.GraphicalViewElement.TimelineEnd = ViewModel.Max( T => T.End );
radGanttView1.GanttViewElement.GraphicalViewElement.TimelineRange = TimeRange.Day;
radGanttView1.GanttViewElement.ChildMember = "Text";
radGanttView1.GanttViewElement.TitleMember = "Text";
radGanttView1.GanttViewElement.StartMember = "Start";
radGanttView1.GanttViewElement.EndMember = "End";
radGanttView1.DataSource = ViewModel;
}
}
Currently, the possible solution that I can suggest is to increase the view's end with 1 hour:
radGanttView1.GanttViewElement.GraphicalViewElement.TimelineEnd = ViewModel.Max( T => T.End.AddHours(1));
Please refer to the attached gif file.
Steps :Please use the following code snippet. Activate the editor for a cell and click another cell:
private DataSet weddingPlan;
public DataSet WeddingPlan {
get
{
if(weddingPlan == null)
{
weddingPlan = new DataSet();
using (StreamReader rdr = new StreamReader("TelerikWeddingPlanner.xml"))
{
weddingPlan.ReadXml(rdr);
}
}
return weddingPlan;
}
}
public Form1()
{
InitializeComponent();
// Events
this.radGanttView1.GanttViewElement.EditorRequired += GanttViewElement_EditorRequired;
this.radGanttView1.GanttViewElement.EditorInitialized += GanttViewElement_EditorInitialized;
this.radGanttView1.GanttViewElement.ItemValidating += GanttViewElement_ItemValidating;
this.radGanttView1.GanttViewElement.ItemValidated += GanttViewElement_ItemValidated;
this.radGanttView1.GanttViewElement.ItemEdited += GanttViewElement_ItemEdited;
}
private void GanttViewElement_DoubleClick(object sender, EventArgs e)
{
Debug.WriteLine("GanttViewElement_DoubleClick");
}
private void GanttViewElement_EditorRequired(object sender, GanttViewEditorRequiredEventArgs e)
{
Debug.WriteLine("GanttViewElement_EditorRequired");
}
private void GanttViewElement_EditorInitialized(object sender, GanttViewItemEditorInitializedEventArgs e)
{
Debug.WriteLine("GanttViewElement_EditorInitialized");
}
private void GanttViewElement_ItemValidated(object sender, GanttViewItemValidatedEventArgs e)
{
Debug.WriteLine("GanttViewElement_ItemValidated");
}
private void GanttViewElement_ItemValidating(object sender, GanttViewItemValidatingEventArgs e)
{
Debug.WriteLine("GanttViewElement_ItemValidating");
Debug.WriteLine(e.Column.FieldName);
e.Cancel = true;
}
private void GanttViewElement_ItemEdited(object sender, GanttViewItemEditedEventArgs e)
{
Debug.WriteLine("GanttViewElement_ItemEdited");
}
private void Form1_Load(object sender, EventArgs e)
{
this.radGanttView1.DataSource = WeddingPlan;
this.radGanttView1.GanttViewElement.TaskDataMember = "Tasks";
this.radGanttView1.GanttViewElement.ChildMember = "Id";
this.radGanttView1.GanttViewElement.ParentMember = "ParentId";
this.radGanttView1.GanttViewElement.TitleMember = "Title";
this.radGanttView1.GanttViewElement.StartMember = "Start";
this.radGanttView1.GanttViewElement.EndMember = "Finish";
this.radGanttView1.GanttViewElement.ProgressMember = "Progress";
this.radGanttView1.GanttViewElement.LinkDataMember = "Links";
this.radGanttView1.GanttViewElement.LinkStartMember = "StartId";
this.radGanttView1.GanttViewElement.LinkEndMember = "EndId";
this.radGanttView1.GanttViewElement.LinkTypeMember = "LinkType";
this.radGanttView1.GanttViewElement.Columns.Add(new GanttViewTextViewColumn("Id"));
this.radGanttView1.GanttViewElement.Columns.Add(new GanttViewTextViewColumn("ParentId"));
this.radGanttView1.GanttViewElement.Columns.Add(new GanttViewTextViewColumn("Title"));
this.radGanttView1.GanttViewElement.Columns.Add(new GanttViewTextViewColumn("Start"));
this.radGanttView1.GanttViewElement.Columns.Add(new GanttViewTextViewColumn("Finish"));
this.radGanttView1.GanttViewElement.Columns[0].Visible = false;
this.radGanttView1.GanttViewElement.Columns[1].Visible = false;
this.radGanttView1.GanttViewElement.Columns[2].Width = 350;
this.radGanttView1.GanttViewElement.Columns[3].Width = 120;
this.radGanttView1.GanttViewElement.Columns[4].Width = 120;
this.radGanttView1.GanttViewElement.GraphicalViewElement.TimelineRange = TimeRange.Month;
this.radGanttView1.GanttViewElement.GraphicalViewElement.TimelineStart = new DateTime(2006, 8, 21);
this.radGanttView1.GanttViewElement.GraphicalViewElement.TimelineEnd = new DateTime(2007, 4, 3);
}
private void radGanttView1_ItemChildIdNeeded(object sender, GanttViewItemChildIdNeededEventArgs e)
{
int max = int.MinValue;
foreach (DataRow row in (this.radGanttView1.DataSource as DataSet).Tables[0].Rows)
{
if (int.Parse(row[0].ToString()) > max)
{
max = int.Parse(row[0].ToString());
}
}
e.ChildId = ++max;
}
I have integration radscheduler and radganttview.
Load data
Dim ds as new DataSource
Dim dvAppointments As New DataView
Dim appointmentMappingInfo As New AppointmentMappingInfo()
Dim SchedSource As New SchedulerBindingDataSource()
appointmentMappingInfo.Mappings.Add(New SchedulerMapping("Kontrahent", "pln_kntakronim"))
appointmentMappingInfo.Start = "pln_start"
appointmentMappingInfo.End = "pln_stop"
appointmentMappingInfo.Location = "pln_nr"
appointmentMappingInfo.ResourceId = "pln_zamgidnumer"
appointmentMappingInfo.Description = "pln_opis"
appointmentMappingInfo.Resources = ""
appointmentMappingInfo.Location = "pln_nrzam"
appointmentMappingInfo.Summary = "pln_twrkod"
appointmentMappingInfo.StatusId = "pln_status"
dvAppointments.Table = ds.Tables("PlanowanieTamborow")
SchedSource.EventProvider.Mapping = appointmentMappingInfo
bsPlanowanie.DataSource = dvAppointments 'BindingSource
SchedSource.EventProvider.DataSource = bsPlanowanie
RadScheduler1.DataSource = SchedSource
RadGanttView1.DataProvider = New GanttViewIntegrationProvider(RadScheduler1)
refresh data
Dim reader As System.Data.SqlClient.SqlDataReader = comm.ExecuteReader
ds.Tables("PlanowanieTamborow").Clear()
ds.Tables("PlanowanieTamborow").Load(reader)
ds.Tables("PlanowanieTamborow").AcceptChanges()
ds.Tables("PlanowanieTamborow")
If I refresh the Radscheduler then RadGanttView doesn't refresh
Radscheduleris working properly
Run the attached sample project and select the second page. You will notice that the tasks are missing. This used to work in R2 2019 (version 2019.2.508).
Workaround: Initialize the RadGanttView.BindingContext before adding it to the page:
Dim Gantt As New RadGanttView
Please use the following code snippet to setup the Gantt view:
Sub New()
InitializeComponent()
Dim dt As New DataTable
dt.Columns.Add("ID", GetType(Integer))
dt.Columns.Add("Group_ID", GetType(Integer))
dt.Columns.Add("Title", GetType(String))
dt.Columns.Add("Start", GetType(DateTime))
dt.Columns.Add("End", GetType(DateTime))
dt.Rows.Add(-999, 0, "Root", New DateTime(2019, 8, 21), New DateTime(2019, 8, 30))
dt.Rows.Add(6, -999, "Item 1", New DateTime(2019, 8, 21), New DateTime(2019, 8, 23))
dt.Rows.Add(7, -999, "Item 2", New DateTime(2019, 8, 26), New DateTime(2019, 8, 30))
dt.Rows.Add(1000, 6, "Sub1.1", New DateTime(2019, 8, 21), New DateTime(2019, 8, 22))
dt.Rows.Add(1001, 6, "Sub1.2", New DateTime(2019, 8, 22), New DateTime(2019, 8, 23))
dt.Rows.Add(1002, 6, "Sub1.3", New DateTime(2019, 8, 23), New DateTime(2019, 8, 23))
dt.Rows.Add(1003, 7, "Sub2.1", New DateTime(2019, 8, 26), New DateTime(2019, 8, 29))
Me.RadGanttView1.DataSource = dt
Me.RadGanttView1.ChildMember = "ID"
Me.RadGanttView1.ParentMember = "Group_ID"
Me.RadGanttView1.TitleMember = "Title"
Me.RadGanttView1.StartMember = "Start"
Me.RadGanttView1.EndMember = "End"
Me.RadGanttView1.Columns.Add("ID")
Me.RadGanttView1.Columns.Add("Title")
Me.RadGanttView1.GanttViewElement.GraphicalViewElement.TimelineStart = New DateTime(2019, 8, 20)
End Sub
However, if you switch the order of adding the rows, not all items will be visible in RadGanttView:
dt.Rows.Add(1000, 6, "Sub1.1", New DateTime(2019, 8, 21), New DateTime(2019, 8, 22))
dt.Rows.Add(1001, 6, "Sub1.2", New DateTime(2019, 8, 22), New DateTime(2019, 8, 23))
dt.Rows.Add(1002, 6, "Sub1.3", New DateTime(2019, 8, 23), New DateTime(2019, 8, 23))
dt.Rows.Add(1003, 7, "Sub2.1", New DateTime(2019, 8, 26), New DateTime(2019, 8, 29))
Please refer to the attached sample project and run it. Select a random item and press the button. You will obtain the error. If no selection is available, the item is removed as expected.
Workaround: use Begin/EndUpdate block while deleting a record from the DataTable:
Please run the attached sample project. Select one of the child tasks and click the button. The new task is expected to be inserted at the selected item's position. However, it is appended at the bottom as it is demonstrated in the gif file.
Workaround: rebind RadGanttView after inserting a new row to the DataTable:
Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
The latest release of WinForms causes a fatal exception when adding an item to a BindingList that is used in a RadGridView and a RadGanttView.
The first time an item is added there is not issue.
The second time an item is added, the following exception occurs.
System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.WinControls.UI.GanttViewBindingProvider.GanttTaskList.IndexOf(Object key)
at Telerik.WinControls.UI.GanttViewBindingProvider.GanttTaskList.get_Item(Object key)
at Telerik.WinControls.UI.GanttViewBindingProvider.AddTaskByCM(CurrencyManager cm, Int32 index)
at System.ComponentModel.ListChangedEventHandler.Invoke(Object sender, ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.OnListChanged(ListChangedEventArgs e)
at System.Windows.Forms.CurrencyManager.List_ListChanged(Object sender, ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.OnListChanged(ListChangedEventArgs e)
at System.ComponentModel.BindingList`1.FireListChanged(ListChangedType type, Int32 index)
at MissileWarningThreatPlanner.EventWindow.EventList.GenMissileEventWorker_RunWorkerCompleted(Object sender, RunWorkerCompletedEventArgs e) in C:\Shape Source\VS\MissileWarningThreatPlanner - VS2010\MissileWarningThreatPlanner\EventWindow\EventList.cs:line 5329
at System.ComponentModel.BackgroundWorker.OnRunWorkerCompleted(RunWorkerCompletedEventArgs e)
This is code that has not been modified for quite some time. There has been no issue until the latest release.
I do not have time to try to create a simple example to try to reproduce the error at this time. I will if possible.
For now, we are forced to revert to a previous version.
Ken...
Hi,
why is the datatype of the ChildMember/ParentMember item limited to Int32? This is a problem when displaying tasks or events from tables with string or UUID idents. It would be a more flexible control if the type could be any type. Should not be a big deal to change this or is it?
Thank you und kind regards
Karsten
Hey,
We have a problem with the GanttViewTimeLineContainer as you see in the screeshot : gantt_print2.png
When we are in TimeLineRange = TimeRange.Year and we print the gantt, we have a problem with the appearence of GanttViewTimeLineContainer, we can see the first line with the year (it's ok) but after, the second line we can see a reperition of all month : jfmamjjasond jfmamjjasond jfmamjjasond jfmamjjasond etc etc etc
Can we change the appearence ? Do you have an explanation for this visualization ?
Thank you,
Regards,
Valériane E.
To reproduce: please run the sample project and follow the steps illustrated in the attached gif file. This shows how I’m attempting to add children to a root task. Upon adding a child task I am unable to scroll down to see the rest of the pre-existent root tasks until I first collapse and expand any visible root or child task. Workaround: public RadForm2() { InitializeComponent(); this.radGanttView1.ItemAdded += radGanttView1_ItemAdded; } private void radGanttView1_ItemAdded(object sender, Telerik.WinControls.UI.GanttViewItemAddedEventArgs e) { item = e.Item; } GanttViewDataItem item; private void radButton1_Click(object sender, EventArgs e) { this.radGanttView1.GanttViewElement.InvalidateMeasure(true); this.radGanttView1.GanttViewElement.UpdateLayout(); this.radGanttView1.GanttViewElement.GraphicalViewElement.Scroller.ScrollToItem(item); }
To reproduce: run the sample project and try to move a task. Workaround: Timer timer = new Timer(); private void DragDropService_Stopped(object sender, EventArgs e) { timer = new Timer(); timer.Interval = 300; timer.Tick += timer_Tick; } private void timer_Tick(object sender, EventArgs e) { timer.Stop(); data.Tables["Tasks"].Clear(); } Workaround 2: private void radGanttView1_ItemElementCreating(object sender, Telerik.WinControls.UI.GanttViewItemElementCreatingEventArgs e) { if (e.Item.Items.Count == 0 && e.ViewElement is GanttViewGraphicalViewElement) { e.ItemElement = new MyGanttViewTaskItemElement(e.ViewElement as GanttViewGraphicalViewElement); } } public class MyGanttViewTaskItemElement : GanttViewTaskItemElement { public MyGanttViewTaskItemElement(GanttViewGraphicalViewElement ganttViewBaseViewElement) : base(ganttViewBaseViewElement) { } protected override Type ThemeEffectiveType { get { return typeof(GanttViewTaskItemElement); } } public override void Detach() { var obj = this.Data; this.Data.SuspendPropertyNotifications(); base.Detach(); obj.ResumePropertyNotifications(); } public override void Synchronize() { DataSet ds = this.Data.GanttViewElement.DataSource as DataSet; if (ds != null && this.Data != null) { DataRowView rowView = this.Data.DataBoundItem as DataRowView; if (rowView != null && !RowExists(rowView.Row))//!ds.Tables[0].Rows.Contains(rowView.Row)) { return; } } base.Synchronize(); } private bool RowExists(DataRow dataRow) { DataSet ds = this.Data.GanttViewElement.DataSource as DataSet; bool res = false; foreach (DataRow r in ds.Tables[0].Rows) { if (r.Equals(dataRow)) { return true; } } return res; } }
To reproduce: run the sample project and scroll to the end of the view. You will notice that the tasks are not properly aligned. You can increase the GraphicalViewElement.OnePixelTime in order to make the alignment even worse. Workaround: Adjust the GraphicalViewElement.OnePixelTime in order to obtain the correct alignment.
To reproduce: 1) Open the Demo application >> Settings example. 2) Select a task and activate the editor for it. 3) Delete the task by clicking the button above. It may be necessary to repeat the steps several times. The error is not reproduced immediately.