Completed
Last Updated: 20 Oct 2011 10:47 by ADMIN
ADMIN
Ivan Petrov
Created on: 20 Oct 2011 10:47
Category: GridView
Type: Feature Request
1
Binding to a list of objects that implement an interface which implements another interface does not work.
Steps to recreate this scenario:
Create an interface e.g. IBaseInterface with couple of properties.
Create another interface e.g. IChildInterface which implements the first one
Create a class which implements the second interface.
Create a list with items of type the child interface.
Fill the list with objects of type the class.
THE PROBLEM IS VALID ONLY FOR 2.0 NET FRAMEWORK!
FIXED TO WORK WITH ALL VERSIONS UNCLUDING TREEVIEW!
When a control is bound to this list it will only "see" the properties defined in the child interface.
test:
----------------------------------------------
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Telerik.WinControls.UI;
namespace Lab.Grid
{
public partial class GridInterfaceInheritanceBinding : MainForm
{
private RadGridView gridView = new RadGridView();
private RadDropDownList comboBox = new RadDropDownList();
public GridInterfaceInheritanceBinding()
{
InitializeComponent();
gridView.Dock = DockStyle.Fill;
gridView.Parent = this;
gridView.BringToFront();
comboBox.Width = 200;
comboBox.Parent = this;
comboBox.BringToFront();
Random r = new Random(DateTime.Now.Second);
List<ITelephone> phones = new List<ITelephone>();
for (int i = 0; i < 10; i++)
{
Telephone phone = new Telephone();
phone.Type = r.Next(3) + 1;
phone.Primary = true;
phone.PRI = i;
phone.ParentType = 1;
phone.Number = "1-800-555-555" + i.ToString();
phone.LockedOn = null;
phone.LockedBy = null;
phone.Locked = 0;
phone.ID = new Guid();
phone.Deleted = false;
phone.Archived = false;
phone.Active = true;
phones.Add(phone);
}
comboBox.DisplayMember = "Number";
comboBox.ValueMember = "PRI";
comboBox.DataSource = phones;
gridView.DataSource = phones;
}
}
public interface IBusinessObject
{
long PRI { get; set; }
bool Active { get; set; }
bool Archived { get; set; }
bool Deleted { get; set; }
byte Locked { get; set; }
string LockedBy { get; set; }
DateTime? LockedOn { get; set; }
Guid ID { get; set; }
}
public interface IStandardLinkTable : IBusinessObject
{
long? ParentPRI { get; set; }
int? ParentType { get; set; }
int? Type { get; set; }
}
public interface ITelephone : IStandardLinkTable
{
string Number { get; set; }
bool? Primary { get; set; }
}
public class Telephone : IBusinessObject, ITelephone
{
public System.Guid ID { get; set; }
private System.Guid _originalid { get; set; }
public System.Int64 PRI { get; set; }
private System.Int64 _originalpri { get; set; }
public System.Byte Class { get; set; }
private System.Byte _originalclass { get; set; }
public System.Int64? ParentPRI { get; set; }
private System.Int64? _originalparentpri { get; set; }
public System.Int32? ParentType { get; set; }
private System.Int32? _originalparenttype { get; set; }
public System.Int32? Type { get; set; }
private System.Int32? _originaltype { get; set; }
public System.String Number { get; set; }
private System.String _originalnumber { get; set; }
public System.Boolean? Primary { get; set; }
private System.Boolean? _originalprimary { get; set; }
public System.Byte Locked { get; set; }
private System.Byte _originallocked { get; set; }
public System.String LockedBy { get; set; }
private System.String _originallockedby { get; set; }
public System.DateTime? LockedOn { get; set; }
private System.DateTime? _originallockedon { get; set; }
public System.Boolean Active { get; set; }
private System.Boolean _originalactive { get; set; }
public System.Boolean Archived { get; set; }
private System.Boolean _originalarchived { get; set; }
public System.Boolean Deleted { get; set; }
private System.Boolean _originaldeleted { get; set; }
internal void SetInitialValues()
{
_originalid = ID;
_originalpri = PRI;
_originalclass = Class;
_originalparentpri = ParentPRI;
_originalparenttype = ParentType;
_originaltype = Type;
_originalnumber = Number;
_originalprimary = Primary;
_originallocked = Locked;
_originallockedby = LockedBy;
_originallockedon = LockedOn;
_originalactive = Active;
_originalarchived = Archived;
_originaldeleted = Deleted;
}
}
}
0 comments