OBJECT Binding

Posted by: ramnath-fp on 8 September 2017, 2:14 pm EST

  • Posted 8 September 2017, 2:14 pm EST

    /This  is city class<br><p>public class Cls_City<br>    {<br>        public Cls_City()<br>        {<br>        }<br><br>        public Cls_City (string cityid, string cityName, string cityState)<br>        {<br>            m_Id = cityid;<br>            mName = cityName;<br>            mStateName = cityState;<br>        }<br>        private string m_Id ;<br>        public string Id<br>        {<br>            get { return m_Id ; }<br>            set { m_Id  = value; }<br>        }<br>        private string mName;<br><br>        public string CityName<br>        {<br>            get { return mName; }<br>            set { mName = value; }<br>        }<br>        private string mStateName;<br><br>        public string StateName<br>        {<br>            get { return mStateName; }<br>            set { mStateName = value; }<br>        }<br>    } <br></p><p>///// This Customer class have cls_City as propery. </p><p> public class Cls_Customer<br>    {<br>        public Dictionary<string, object> dictionary = new Dictionary<string, object>();<br>        public Cls_Customer(string custId, string custName, string custType, string custMobile, Cls_City custCity)<br>        {<br>            mCustid = custId;<br>            mType = custType;<br>            mName = custName;<br>            mMobile = custMobile;<br>            mCity = custCity;<br>        }<br><br>        private string mCustid;<br><br>        public string Id<br>        {<br>            get { return mCustid; }<br>            set { mCustid = value; }<br>        }<br>        private string mType;<br><br>        public string Type<br>        {<br>            get { return mType; }<br>            set { mType = value; }<br>        }<br>        private string mName;<br><br>        public string Name<br>        {<br>            get { return mName; }<br>            set { mName = value; }<br>        }<br>        private string mMobile;<br><br>        public string MobileNumber<br>        {<br>            get { return mMobile; }<br>            set { mMobile = value; }<br>        }<br>        private Cls_City mCity;<br>        public Cls_City City<br>        {<br>            get<br>            {<br>                return mCity;<br>            }<br>            set<br>            {<br>                mCity = City;<br>            }<br>        }</p><p>// I want display these data in spread.</p><p>/// How i display city and state with the help of city property of the customer class. </p><p> System.ComponentModel.BindingList<Cls_City> citiesList=new BindingList<Cls_City>();<br>            System.ComponentModel.BindingList<Cls_Customer> cList =new BindingList<Cls_Customer>();<br>            citiesList.Add(new Cls_City("1", "Mumbai",  "Maharashtra"));<br>            citiesList.Add(new Cls_City("2", "Pune", "Maharashtra"));<br>            citiesList.Add(new Cls_City("3", "Delhi", "UP"));<br>            citiesList.Add(new Cls_City("4", "Bangalore", "Karnataka"));<br>            citiesList.Add(new Cls_City("5", "Surat", "Gujarat"));<br><br>            cList.Add(new Cls_Customer("10", "Mahesh", "Debtor", "123654", citiesList[0]));<br>            cList.Add(new Cls_Customer("20", "Ravi", "Creditor", "859647", citiesList[1]));<br>            cList.Add(new Cls_Customer("30", "John", "Debtor", "78965", citiesList[2]));<br><br>            Sp_Cust_Sht1.DataSource = cList;<br>            Sp_Cust_Sht1.Columns[0].DataField = "Id";<br>            Sp_Cust_Sht1.Columns[1].DataField = "Type";<br>            Sp_Cust_Sht1.Columns[2].DataField = "Name";<br>            Sp_Cust_Sht1.Columns[3].DataField = "MobileNumber";<br>            Sp_Cust_Sht1.Columns[4].DataField = "City.CityName"; //// Not display data ??????????????????????????<br>           Sp_Cust_Sht1.Columns[5].DataField = "City.StateName"; //// Not display data ??????????????????????????</p><p> </p><p> </p><p> </p><p>regards,</p><p>Ram Nath </p><p>INDIA <br></p>
  • Replied 8 September 2017, 2:14 pm EST

    <p>Hi Ram,</p><p>Spread does not support that syntax for sub-properties.  You would need to add properties to your customer class to wrap the properties in the city class.</p><p>Do you know of any data bound controls which support that sort of syntax?  I can submit an enhancement request to improve this behavior, and showing other controls which already support it improves the chances of it getting implemented. <br></p>
  • Replied 8 September 2017, 2:14 pm EST

    <p>Hi,</p><p>In farpoint inputpro we can bind like this. <br></p><p>fpno.DataBindings.Add(new Binding("Text", CurrentObject, "City.StateName")); </p><p> </p><p>Is possible to set spread column data field like this:-</p><p> Sp_Cust_sht1.Columns[0].DataField="City.StateName";</p><p> </p><p>Please repply me</p><p>Thanks and regards,</p><p>Ram Nath</p><p>MUMBAI(INDIA) <br></p>
  • Replied 8 September 2017, 2:14 pm EST

    <p>Hello,
    </p><p>In order to set the DataField you may use  the following approach:</p><p>            BindingList<Cls_City> Records = new BindingList<Cls_City>();     <br>            fpSpread1.ActiveSheet.AutoGenerateColumns =false;    <br>            fpSpread1.ActiveSheet.DataSource = Records;  <br>            fpSpread1.ActiveSheet.Columns[0].DataField = "StateName"; </p><p>I hope it will help you.</p><p>Thanks,</p><p> </p><p> </p>
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels