This is a migrated thread and some comments may be shown as answers.

How to limit the number of displayed characters in RadItem?

1 Answer 41 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
Serg
Top achievements
Rank 1
Veteran
Serg asked on 19 Jan 2021, 10:13 AM

How do I limit the number of characters shown when the text is too long?

For the text "Very Long Text Very Very Long" to take the form "Very Long Text ..."

OR text "VeryLongTextVeryVeryLong" to take the form "VeryLongTextV..."

1 Answer, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 20 Jan 2021, 06:02 AM

Hello, Serg, 

Generally, you can limit the size of the context menu by setting the DropDown.MaximumSize property. It is necessary to restrict the menu item as well. 

 

        RadContextMenu menu = new RadContextMenu();

        public Form1()
        {
            InitializeComponent();

            RadLabelElement lbl = new RadLabelElement();
            lbl.Text = "Very Long Text Very Very Long";
            lbl.TextWrap = false;
            RadMenuItem item = new RadMenuItem();
            item.Children.Add(lbl);
            menu.Items.Add(item);
            item.MaxSize = lbl.MaxSize = new System.Drawing.Size(70,0); 
            menu.DropDown.MaximumSize = new Size(100, 0); 
        }

        private void radButton1_Click(object sender, EventArgs e)
        {
            menu.Show(MousePosition);
        }

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
ContextMenu
Asked by
Serg
Top achievements
Rank 1
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or