Hi,
I have two Class Employee & Manager and manager class looks like that
public class Manager
{
public string Name { get; set; }
public string Description { get; set; }
public BindingList<Employee> Employees { get; set; }
public Manager()
{
Employees = new BindingList<Employee>();
}
}
I have created parent child relationship with UltraWinGrid with Manager & employee. I have one textbox in which I want to display corresponding employee whenever use clicks on the employee records from child of WinGrid. I am trying to bind the textEditor using the DataBinding like this
this.ultraTextEditor2.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.employeeBindingSource, "Description", true));
Here is code snippet I am using to test the issue here
Two classes Manager, Empoyees
Manager.CS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
namespace MultiBandTest1
{
public class Manager
{
public string Name { get; set; }
public string Description { get; set; }
public BindingList<Employee> Employees { get; set; }
public Manager()
{
Employees = new BindingList<Employee>();
}
}
}
Employee.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MultiBandTest1
{
public class Employee
{
public string Name { get; set; }
public string Description { get; set; }
}
}
and Final Code snippet for 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;
namespace MultiBandTest1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
managerBindingSource.DataSource = CreateManagers();
}
protected BindingList<Manager> CreateManagers()
{
Manager m1 = new Manager();
m1.Name = "Joe";
m1.Description = "Description for Joe";
Manager m2 = new Manager();
m2.Name = "Steve";
m2.Description = "Description for Steve";
Employee e1 = new Employee();
e1.Name = "Dan";
e1.Description = "Description for Dan";
Employee e2 = new Employee();
e2.Name = "Rick";
e2.Description = "Description for Rick";
m1.Employees.Add(e1);
m1.Employees.Add(e2);
Employee e3 = new Employee();
e3.Name = "Ron";
e3.Description = "Description for Ron";
Employee e4 = new Employee();
e4.Name = "Mike";
e4.Description = "Description for Mike";
m2.Employees.Add(e3);
m2.Employees.Add(e4);
BindingList<Manager> managers = new BindingList<Manager>();
managers.Add(m1);
managers.Add(m2);
return managers;
}
}
}
Code to Binding TextEditor &
// ultraTextEditor1
//
this.ultraTextEditor1.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.managerBindingSource, "Description", true));
this.ultraTextEditor1.Location = new System.Drawing.Point(143, 396);
this.ultraTextEditor1.Name = "ultraTextEditor1";
this.ultraTextEditor1.Size = new System.Drawing.Size(500, 21);
this.ultraTextEditor1.TabIndex = 2;
//
// ultraTextEditor2
//
this.ultraTextEditor2.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.employeeBindingSource, "Description", true));
this.ultraTextEditor2.Location = new System.Drawing.Point(142, 425);
this.ultraTextEditor2.Name = "ultraTextEditor2";
this.ultraTextEditor2.Size = new System.Drawing.Size(500, 21);
this.ultraTextEditor2.TabIndex = 4;
//
// employeeBindingSource
//
this.employeeBindingSource.DataMember = "Employees";
this.employeeBindingSource.DataSource = this.managerBindingSource;
//
// ultraLabel2
//
this.ultraLabel2.Location = new System.Drawing.Point(12, 425);
this.ultraLabel2.Name = "ultraLabel2";
this.ultraLabel2.Size = new System.Drawing.Size(124, 23);
this.ultraLabel2.TabIndex = 3;
this.ultraLabel2.Text = "Employee Description";
//
// managerBindingSource
//
this.managerBindingSource.DataSource = typeof(MultiBandTest1.Manager);
I am not sure why child records are not yet displaying when I click on the child records am I missing anything there. Please let me know as soon as possible. Thank you.