NullText Property doesn't work in RadDropDown

15 posts, 0 answers
  1. Nick Gebbett
    Nick Gebbett avatar
    13 posts
    Member since:
    May 2010

    Posted 28 Sep 2010 Link to this post

    this.RadDropDownList_LocationType.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
    this.RadDropDownList_LocationType.Location = new System.Drawing.Point(4, 4);
    this.RadDropDownList_LocationType.Name = "RadDropDownList_LocationType";
    this.RadDropDownList_LocationType.NullText = "Please Select";
    this.RadDropDownList_LocationType.Size = new System.Drawing.Size(123, 18);
    this.RadDropDownList_LocationType.TabIndex = 0;
    When I Use RadComboBox instead RadDropDown property works.
  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 29 Sep 2010 Link to this post

    Hello Alexander,

    Yes, this is true, when the DropDownStyle is set to DropDownList the null text is no longer visible, but the Text property should work fine as a NullText until a fix will be issued.

    Best Regards,
    Emanuel Varga
  3. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 01 Oct 2010 Link to this post

    Indeed, Emanuel is correct. 
     
    By design the text defined by the NullText property is displayed in the editor's input box when the editor is not in DropDownList mode. We actually set  RadTextBox's Null Text property but in DropDownList mode this textbox is not visible. This is why you can't see the Null text.
     
    I hope this explanation clarifies the situation.

    Sincerely yours,

    Peter
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  4. Nick Gebbett
    Nick Gebbett avatar
    13 posts
    Member since:
    May 2010

    Posted 05 Oct 2010 Link to this post

    I definitely not understand why this is designed and how to show user "Please select" option when SelectedValue = null
  5. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 06 Oct 2010 Link to this post

    Hello Alexander,

    The solution I've offered would do the trick, like i said, assign to the Text property the text you want to show when no item is selected, after the user selects something from the list, that text will no longer be visible. One downside of that is the fact that it's not a faded text and it's not italic.

    In my point of view, if and until that NullText property will work for the DropDownList style, this is the way to go (or create a dummy first element in your collection, handle the selected index changed event, and when new index != 0 remove that element from the collection)

    Hope this helps, if you have any other questions, please let me know,

    Best Regards,
    Emanuel Varga
  6. Nick Gebbett
    Nick Gebbett avatar
    13 posts
    Member since:
    May 2010

    Posted 07 Oct 2010 Link to this post

    In case of my application it is not an option to use DropDownStyle.DropDown
    So you are right, the only way I see is to create a dummy objects in all DropDowns. Thank you.
    But it is not useful.

    I'm trying to understand why RadDropDown works like that. What so bad will happene if RadDropDown.NullText shows the string I need in DropDownList mode? =)
  7. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 07 Oct 2010 Link to this post

    Hello Alexander,

    I completely agree with you that the null text should be shown whenever there is no item selected in a DropDownList, but until they will fix this, i would suggest you try this workaround:
    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;
    using Telerik.WinControls.UI;
     
    namespace TestDropDownListNullText
    {
         
        public partial class Form1 : Form
        {
            public RadDropDownList radDropDownList1;
            public Form1()
            {
                InitializeComponent();
                this.Load += new EventHandler(Form1_Load);
            }
     
            void Form1_Load(object sender, EventArgs e)
            {
                radDropDownList1 = new RadDropDownList();
                radDropDownList1.Dock = DockStyle.Top;
     
                this.Controls.Add(radDropDownList1);
     
                radDropDownList1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
                radDropDownList1.PopupClosing += new RadPopupClosingEventHandler(radDropDownList1_PopupClosing);
                radDropDownList1.DataSource = new TestsCollection(10);
                radDropDownList1.DisplayMember = "Name";
                radDropDownList1.Text = "Please select something...";
            }
     
            void radDropDownList1_PopupClosing(object sender, RadPopupClosingEventArgs args)
            {
                if (string.IsNullOrEmpty(radDropDownList1.Text))
                {
                    radDropDownList1.Text = "Please select something...";
                }
            }
        }
     
        #region Business Objects
     
        public class Test
        {
            public int Id
            {
                get;
                set;
            }
     
            public string Name
            {
                get;
                set;
            }
     
            public Test(int id, string name)
            {
                this.Id = id;
                this.Name = name;
            }
        }
     
        public class TestsCollection : List<Test>
        {
            public TestsCollection(int noItems)
            {
                for (int i = 0; i < noItems; i++)
                {
                    this.Add(new Test(i, "test" + i));
                }
            }
        }
     
        #endregion Business Objects
    }

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
  8. François
    François  avatar
    1 posts
    Member since:
    Feb 2011

    Posted 30 Nov 2011 Link to this post

    Is this feature in telerik roadmap? To see nulltext with null value as first item when  DropDownStyle is set to DropDownList?
  9. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 05 Dec 2011 Link to this post

    Hello Alexander,

    Thanks for writing back.

    You can easily workaround this by setting the Text property instead of NullText property in this mode.
    Please refer to the attached project. Also, you can use the Emanuel's solution.

    I hope this helps.

    All the best,
    Peter
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  10. Jared
    Jared avatar
    19 posts
    Member since:
    Oct 2015

    Posted 10 May 2018 in reply to François Link to this post

    Please vote to have this feature added to DropDownList here:

     

    https://feedback.telerik.com/Project/154/Feedback/Details/249059-add-nulltext-functionality-to-raddropdownlist-when-in-dropdownstyle-is-dropdownli

  11. Hristo
    Admin
    Hristo avatar
    1508 posts

    Posted 11 May 2018 Link to this post

    Hello Jared,

    As my colleague has written earlier in the thread the NullText property is rendered by the input text box. Having the control set up in DropDownList mode will not render the null text. To achieve a similar behavior you can follow the approach already discussed in the thread.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  12. Mehdi
    Mehdi avatar
    9 posts
    Member since:
    Jan 2018

    Posted 23 Aug 2018 Link to this post

    Hi guys.

    I'm read thread. but cannot find my solution.

    need to wait for new update?

  13. Hristo
    Admin
    Hristo avatar
    1508 posts

    Posted 24 Aug 2018 Link to this post

    Hi Mehdi,

    We have a feature request logged on our feedback portal, here: ADD. RadDropDownList - NullText functionality to RadDropDownList when in DropDownStyle is DropDownList.. Please subscribe to the item so that you can be updated when its status changes.

    Regards,
    Hristo
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  14. Mehdi
    Mehdi avatar
    9 posts
    Member since:
    Jan 2018

    Posted 24 Aug 2018 Link to this post

    Hi Hristo.

    I'm Subscribe and wait for update.

    but i can to solve this problem by this snipped code.

    i'm add this code to Public and after InitializeComponent. this work correctly.

    may another can use this. ;-)

     

    if (txtbadge.SelectedIndex == -1)
                {
                    txtbadge.Text = "please select an item ... ";
                    txtbadge.ForeColor = Color.FromArgb(0, 77, 64);
                }
                else
                {
                    txtbadge.ForeColor = Color.White;
                }
  15. Hristo
    Admin
    Hristo avatar
    1508 posts

    Posted 24 Aug 2018 Link to this post

    Hi Mehdi, 

    Thank you for sharing your solution with the community.

    Regards,
    Hristo
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top