Windows Develop Bookmark and Share   
 index > Windows Forms General > Can not bind child band property to Ultratextbox of Infragistics using BindingSource
 

Can not bind child band property to Ultratextbox of Infragistics using BindingSource

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.

  • Moved byJim Zhou - MSFT Wednesday, September 09, 2009 11:26 AMWindows Forms related issue (From:Windows Presentation Foundation (WPF))
  •  
TestingBuger  Friday, September 04, 2009 4:17 PM
Hi,
-->this.ultraTextEditor2.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.employeeBindingSource, "Description", true));

It seems that this is a Windows Forms application, not a WPF application. I am moving this thread to Windows Forms forum, there are more experts on that technology.

Thanks.
Jim Zhou -MSFT
Jim Zhou - MSFT  Wednesday, September 09, 2009 11:25 AM

You can use google to search for other answers

Custom Search

More Threads

• to select Images in listview
• Keeping main GUI updated while showing FileDialog
• Help with Windows Service Exception in AfterInstall Event
• Setting the BackColor of selected cells in MonthCalendar. Is it doable ?
• Toolstrip Overflow Layout
• Register a Window Class
• Capturing Graphics From RichTextBox
• Read a value from cookie - How to Set Password from Cookie when Mode of Textbox is Password ?
• c# memory problem
• Scanning Images using VB.net