radDataEntry - winforms UI

13 posts, 0 answers
  1. Lloyd
    Lloyd avatar
    1 posts
    Member since:
    Oct 2010

    Posted 02 Apr 2014 Link to this post

    Does anyone know how to get a dropdownlist to function (bindings) on the new radDataEntry form.   I am so frustrated with the lack of examples and documentation with Telerik!  
  2. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 04 Apr 2014 Link to this post

    Hello Lloyd,

    Thank you for writing.

    In general case when your data source contains enumeration the drop down list will appear automatically. The default editors along with their corresponding types are described in the following article: DataEntry.

    If you need to use drop down list as an editor for a custom field that is not enumeration you can change the default editor in the EditorInitializing event:
    void radDataEntry1_EditorInitializing(object sender, Telerik.WinControls.UI.EditorInitializingEventArgs e)
    {
        if (e.Property.Name == "Str")
        {
            RadDropDownList radDropDownList1 = new RadDropDownList();
     
            radDropDownList1.DataSource = valuesList;
            radDropDownList1.ValueMember = "Value";
            radDropDownList1.DisplayMember = "Value";
     
            radDropDownList1.DropDownListElement.StretchHorizontally = true;
     
            e.Editor = radDropDownList1;
        }
    }

    More information about such scenarios is available in the following article: Change auto generated editor.

    I also have attached a small sample to show you how such scenario can be achieved.

    Let me know if you have additional questions.

    Also since you have mentioned that you are frustrated from the lack of documentation, I want to ask you to provide us with more details on what do you find missing in our documentation and examples that you would you like to see there? Your feedback is highly appreciated.
     
    Regards,
    Dimitar
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Michael Hildebrand
    Michael Hildebrand avatar
    13 posts
    Member since:
    Nov 2004

    Posted 01 Jun 2015 Link to this post

    Hello -

    I have a custom dropdownlist editor working with a radDataEntry form/control. The custom dropdownlist has ID (int) and OffierName (string) properties as properties.  In my datasource setting to the radDataEntry control I point a data class that contains a property called OwnerID (int).

    When I display the data entry form, the dropdownlist control appears, and it lists all the DisplayName values in dropdown. What it does not do is preselect the dropdownlist control with the OwnerID in my data class, when the radDataEntry control's datasource is set.  If I select an item in the dropdownlist, it does set the OwnerID correctly in the data class.   

    How do I get the custom dropdownlist editor to preselect, when the radDataEntry control's datasource is set?

     

    Note: I have the 'radDataEntry1_BindingCreating' event setup.

  5. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 02 Jun 2015 Link to this post

    Hi Michael,

    Without the actual code I cannot say why the correct item is not selected in the dropdown editor. However, we have a complete example for this in our documentation: Change the editor to a bound RadDropDownList. If the solution there is not working for your case, I want to kindly ask you to open a support ticket where you can attach your project. This way we will be able to provide you with a proper solution.  

    I hope this will be useful. 

    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Michael Hildebrand
    Michael Hildebrand avatar
    13 posts
    Member since:
    Nov 2004

    Posted 02 Jun 2015 in reply to Dimitar Link to this post

    Hello Dimitar!

    I have already tried the example you suggested above.  I have created another example based on the one you suggested to show my problem.  All you need to do to run it is create a windows form app with a RadDataEntry control on the form.  Here is the code...

    namespace TestDDL
    {
      public partial class Form1 : RadForm
      {
        private List<Supplier> supplierList;

        public Form1()
        {
          InitializeComponent();

          suplierList = new List<Supplier>();
          suplierList.Add(new Supplier(1, "(1) Exotic Liquids"));
          suplierList.Add(new Supplier(2, "(2) New Orleans Cajun Delights"));
          suplierList.Add(new Supplier(3, "(3) Tokyo Traders"));
          suplierList.Add(new Supplier(4, "(4) Norske Meierier"));
          suplierList.Add(new Supplier(5, "(5) New England Seafood Cannery"));
          suplierList.Add(new Supplier(6, "(6) Leka Trading"));

          // I create the record here to be displayed in the RadDataEntry form
          var record = new Record();
          record.SupplierItem = 3;  // I want the drop down list to initially display item 3 or 'Tokyo Traders'
                                    // This is what is not working ... 

          radDataEntry1.DataSource = record;
        }

        void radDataEntry1_EditorInitializing(object sender, Telerik.WinControls.UI.EditorInitializingEventArgs e)
        {
          if (e.Property.Name == "SupplierItem")
          {
            var radDropDownList1 = new RadDropDownList();

            radDropDownList1.DataSource = suplierList;

            radDropDownList1.ValueMember = "SupplierID";
            radDropDownList1.DisplayMember = "CompanyName";

            e.Editor = radDropDownList1;
          }
        }

        void radDataEntry1_BindingCreating(object sender, Telerik.WinControls.UI.BindingCreatingEventArgs e)
        {
          if (e.DataMember == "SupplierItem")
          {
            e.PropertyName = "SelectedValue";
          }
        }

        void radDataEntry1_BindingCreated(object sender, BindingCreatedEventArgs e)
        {
          if (e.DataMember == "SupplierItem")
          {
            e.Binding.FormattingEnabled = true;
            e.Binding.Parse += new ConvertEventHandler(Binding_Parse);
          }
        }

        private void Binding_Parse(object sender, ConvertEventArgs e)
        {
          int tmpvalue;
          int? result = int.TryParse(e.Value.ToString(), out tmpvalue) ? tmpvalue : (int?)null;

          e.Value = result;
        }
      }

      public class Record
      {
        public int SupplierItem { get; set; }
      }

      public partial class Supplier
      {
        private int? _supplierID;
        private string _companyName;

        public Supplier(int? supplierID, string companyName)
        {
            this._supplierID = supplierID;
            this._companyName = companyName;
        }

        public int? SupplierID
        {
            get
            {
                return this._supplierID;
            }
            set
            {
                this._supplierID = value;
            }
        }

        public string CompanyName
        {
            get
            {
                return this._companyName;
            }
            set
            {
                this._companyName = value;
            }
        }
      }
    }

  7. Michael Hildebrand
    Michael Hildebrand avatar
    13 posts
    Member since:
    Nov 2004

    Posted 02 Jun 2015 in reply to Michael Hildebrand Link to this post

    Sorry misspelt 'supplierList', just change:

    private List<Supplier> supplierList;

    to

    private List<Supplier> suplierList;

    :) Less changes :)

  8. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 03 Jun 2015 Link to this post

    Hello Michael,

    Thank you for writing back.

    This is a known issue and it is already logged in our Feedback Portal. You can track the item for status changes and add your vote for it here.

    Tow workaround the issue you should set the dropdown list parent:
    void radDataEntry1_EditorInitializing(object sender, Telerik.WinControls.UI.EditorInitializingEventArgs e)
    {
        if (e.Property.Name == "SupplierItem")
        {
            var radDropDownList1 = new RadDropDownList();
            radDropDownList1.DataSource = suplierList;
            radDropDownList1.ValueMember = "SupplierID";
            radDropDownList1.DisplayMember = "CompanyName";
            radDropDownList1.Parent = this;
            e.Editor = radDropDownList1;
        }
    }

    In addition you should set the RadDataEntry data source in the form's Load event:
    private void RadForm1_Load(object sender, EventArgs e)
    {
        var record = new Record();
        record.SupplierItem = 3;
        radDataEntry1.DataSource = record;
    }

    I hope this will be useful. 

    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  9. Michael Hildebrand
    Michael Hildebrand avatar
    13 posts
    Member since:
    Nov 2004

    Posted 06 Aug 2015 in reply to Dimitar Link to this post

    I tried the work around above and it work 80% of the time.

    You can test this by taking the code in the Load event and it in a Button event. When the app is run, press the button 20 times and you will see the value incorrectly displayed in the dropdownlist.

    I need this fixed ASAP.  I still own the trial version of telerik, and will be buying soon. Please let me know if there is a fix! Thanks.

  10. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 10 Aug 2015 Link to this post

    Hello Michael,

    Thank you for writing back.

    I have tested this and on my side the workaround is working properly. I have attached my test project. Could please take a look at it and let me know what else I need to in order to reproduce the issue?

    Thank you in advance for your patience and cooperation. 
     
    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  11. Michael Hildebrand
    Michael Hildebrand avatar
    13 posts
    Member since:
    Nov 2004

    Posted 11 Aug 2015 in reply to Dimitar Link to this post

    Hi Dimitar!

    In order to see the issue, the RadDataEntry.DataSource must first be set to null.  I set it to null to clear and refresh all the fields on the RadDataEntry form - some of mine forms have 40+ fields on them.

    To see the issue, replace the follow 2 lines of code in your example (in the 'for' loop):

    1. record.SupplierItem = rnd.Next(5);
    2. radDataEntry1.DataSource = record;

    With these 4 lines of code:

    1. record.SupplierItem = 6;
    2. radDataEntry1.DataSource = null;
    3. radDataEntry1.DataSource = record;
    4. if (record.SupplierItem != 6) RadMessageBox.Show("STOP! SupplierItem changed!");

    Michael

     

  12. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 14 Aug 2015 Link to this post

    Hi Michael,

    Thank you for writing back.

    I was able to reproduce the observed behavior. It appears that when the data source is reset the binding context of the control is changed as well. This resets the position 0. The solution, in this case, would be to update the items without resetting the data source (resetting the data source to update the values is a bad practice because the reset will recreate all visual controls, which is slow operation). I have attached updated version of the sample project to show you how this can be implemented. 

    I hope this will be useful.

    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  13. Michael Hildebrand
    Michael Hildebrand avatar
    13 posts
    Member since:
    Nov 2004

    Posted 14 Aug 2015 in reply to Dimitar Link to this post

    This is very useful. Thank you.  I see how you are using the BindingSource.

    However, when the button click code sets the SupplierItem, the form is never updated.  Here:

          record.SupplierItem = rnd.Next(5);  // Does not update form (I'm using Q1 2015)

    How can I cause the form to update, without resetting the data source?

    Thanks,

    Michael

     

  14. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 14 Aug 2015 Link to this post

    Hello Michael,

    Thank you for writing back.

    The random object can return 0 as value and in this case, the item would not be changed (the data source does not have a value with 0 for ID). You can properly check this with the following code:
    int count = 1;
     
    private void button1_Click(object sender, EventArgs e)
    {
        
        record.SupplierItem = count++;
        if (count == 6)
        {
            count = 1;
        }
    }

    In addition, I have tested this with Q1 2015 assemblies and it is working as expected.

    Do not hesitate to contact us if you have other questions.
     
    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WinForms is Visual Studio 2017 Ready