or
var appointmentMappingInfo = new AppointmentMappingInfo(); appointmentMappingInfo.BackgroundId = "ApptStatus"; appointmentMappingInfo.Description = "Description"; appointmentMappingInfo.End = "EndDate"; //appointmentMappingInfo.Location = "Location"; //appointmentMappingInfo.MasterEventId = "ParentID"; //appointmentMappingInfo.RecurrenceRule = "RecurrenceRule"; appointmentMappingInfo.ResourceId = "ProviderId"; //appointmentMappingInfo.Resources = "SchedulerAppointment"; appointmentMappingInfo.Start = "StartDate"; //appointmentMappingInfo.StatusId = "StatusID"; appointmentMappingInfo.Summary = "Subject"; schedulerBindingDataSource1.EventProvider.Mapping = appointmentMappingInfo; var resourceMappingInfo = new ResourceMappingInfo(); resourceMappingInfo.Id = "Id"; resourceMappingInfo.Name = "Name"; schedulerBindingDataSource1.ResourceProvider.Mapping = resourceMappingInfo; _bsAppts = SchedulerRepository.GetAppointments(); schedulerBindingDataSource1.ResourceProvider.DataSource = _opList; schedulerBindingDataSource1.EventProvider.DataSource = _bsAppts; schMain.DataSource = schedulerBindingDataSource1; _opList is a binding list of your Resource object. _bsAppts is a binding list of my business object appointments Thanks!

var dateColumnOut = new GridViewDateTimeColumn { HeaderText = "Date Time Out", Name = Data.cJobCardData.JobCardColumns.DateTimeOut, FieldName = Data.cJobCardData.JobCardColumns.DateTimeOut, Format = DateTimePickerFormat.Long, EditorType = GridViewDateTimeEditorType.TimePicker, FormatString = "{0: M/d/yyyy h:mm tt}", TextAlignment = ContentAlignment.MiddleCenter, Width = colWidth };private void MoveListBoxItems(ListBox source, ListBox destination)
{
ListBox.SelectedObjectCollection sourceItems = source.SelectedItems;
foreach (var item in sourceItems)
{
destination.Items.Add(item);
}
while (source.SelectedItems.Count > 0)
{
source.Items.Remove(source.SelectedItems[0]);
}
}
private void button1_Click(object sender, EventArgs e)
{
MoveListBoxItems(listBox1, listBox2);
}
private void button2_Click(object sender, EventArgs e)
{
MoveListBoxItems(listBox2, listBox1);
}
Private Sub RadScheduler1_AppointmentAdded(sender As Object, e As Telerik.WinControls.UI.AppointmentAddedEventArgs) Handles RadScheduler1.AppointmentAdded Dim app As AppointmentWithPhone = TryCast(e.Appointment, AppointmentWithPhone) If NameExistsInDB(app.Subject) = False Then Debug.WriteLine("Before: " & RadScheduler1.Appointments.Count) Me.RadScheduler1.Appointments.Remove(app) Debug.WriteLine("After: " & RadScheduler1.Appointments.Count) End If End SubI am creating a hierarchy grid using object relational data. I am adding a GridViewRelation manually to link the two classes together. The data loads correctly at first, but then selecting a child row will cause all child rows in that position to be duplicated and selected.
After initial data load, everything looks great.
(See dataload.png)
Select Child 2_1 and all first position children are selected.
(see select1.png)
Select Child 3_2 and now all second position children are selected, and the first position children are now duplicates of each other and read Child 4_1.
(see select2.png)
Here is the code:
namespace TestGrid{ public partial class Form1 : Form { private BindingList<MasterObject> data; public Form1() { InitializeComponent(); SetupGrid(); } private void SetupGrid() { LoadMasterTemplate(grid.MasterTemplate); GridViewTemplate childTemplate = new GridViewTemplate(); LoadChildTemplate(childTemplate); grid.MasterTemplate.Templates.Add(childTemplate); GridViewRelation relation = new GridViewRelation(grid.MasterTemplate, childTemplate); relation.RelationName = "Children"; relation.ChildColumnNames.Add("Children"); grid.Relations.Add(relation); } private void LoadMasterTemplate(GridViewTemplate template) { template.Columns.Clear(); template.EnableFiltering = false; template.AllowAddNewRow = false; template.ShowChildViewCaptions = false; template.AutoGenerateColumns = false; template.EnableGrouping = false; GridViewTextBoxColumn colNode = new GridViewTextBoxColumn("NodeDesc"); colNode.HeaderText = "Node"; colNode.Name = "Node"; colNode.ReadOnly = true; template.Columns.Add(colNode); GridViewTextBoxColumn colName = new GridViewTextBoxColumn("Name"); colName.HeaderText = "Name"; colName.Name = "Name"; template.Columns.Add(colName); template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; } private void LoadChildTemplate(GridViewTemplate template) { template.Columns.Clear(); template.EnableFiltering = false; template.EnableGrouping = false; template.AllowAddNewRow = false; template.AutoGenerateColumns = false; GridViewTextBoxColumn colNode = new GridViewTextBoxColumn("NodeDesc"); colNode.HeaderText = "Node"; colNode.Name = "Node"; colNode.ReadOnly = true; template.Columns.Add(colNode); GridViewTextBoxColumn colIP = new GridViewTextBoxColumn("Name"); colIP.Name = "Name"; colIP.HeaderText = "Name"; template.Columns.Add(colIP); template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; } private void LoadData() { data = new BindingList<MasterObject>(); for (int i = 1; i < 5; i++) { MasterObject m = new MasterObject(); m.Name = "Master " + i; for (int x = 1; x < i; x++) { ChildObject c = new ChildObject(); c.Name = "Child " + i + "_" + x; m.Children.Add(c); } data.Add(m); } grid.DataSource = data; } private void button1_Click(object sender, EventArgs e) { // Load Data In Grid LoadData(); } private void button2_Click(object sender, EventArgs e) { // Add Child to 1 MasterObject m = data[0]; ChildObject c = new ChildObject(); c.Name = "Child " + "1_" + (m.Children.Count + 1); m.Children.Add(c); } private void button3_Click(object sender, EventArgs e) { // Add Child to 2 MasterObject m = data[1]; ChildObject c = new ChildObject(); c.Name = "Child " + "2_" + (m.Children.Count + 1); m.Children.Add(c); } } public class MasterObject { private string name; public string Name { get { return name; } set { if (name != value) { name = value; } } } public string NodeDesc { get { return "MasterObject"; } } private BindingList<ChildObject> children; public BindingList<ChildObject> Children { get { return children; } set { children = value; } } public MasterObject() { children = new BindingList<ChildObject>(); } } public class ChildObject { private string name; public string Name { get { return name; } set { if (name != value) { name = value; } } } public string NodeDesc { get { return "ChildObject"; } } public ChildObject() { } }}