Completed
Last Updated: 30 Oct 2018 08:56 by Dimitar
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 15 Oct 2018 06:40
Category: TreeView
Type: Bug Report
0
FIX. RadBreadCrumb - disabling the UseMnemonic property of the items doesn't take effect when the RadBreadCrumb.DefaultTreeView is set after subscribing to the treeview events
To reproduce: use the following code snippet. You will notice that mnemonics are displayed.

        public RadForm1()
        {
            InitializeComponent();
            new RadControlSpyForm().Show();

            this.radTreeView1.DisplayMember = "name";
            this.radTreeView1.ParentMember = "pid";
            this.radTreeView1.ChildMember = "id";
            this.radTreeView1.DataSource = this.GetSampleData();
           
            this.radTreeView1.NodeFormatting += radTreeView1_NodeFormatting;
            this.radTreeView1.SelectedNodeChanged += radTreeView1_SelectedNodeChanged;
            
            this.radBreadCrumb1.DefaultTreeView = this.radTreeView1;
        }

        private void radTreeView1_SelectedNodeChanged(object sender, Telerik.WinControls.UI.RadTreeViewEventArgs e)
        {
            foreach (RadSplitButtonElement item in this.radBreadCrumb1.BreadCrumbElement.Items)
            {
                item.ActionButton.TextElement.UseMnemonic = false;
            }
        }
         
        private void radTreeView1_NodeFormatting(object sender, Telerik.WinControls.UI.TreeNodeFormattingEventArgs e)
        {
            e.NodeElement.ContentElement.UseMnemonic = false; 
        }

        private DataTable GetSampleData()
        {
            DataTable dt = new DataTable();

            DataColumn dc = new DataColumn();
            dc.ColumnName = "id";
            dc.DataType = typeof(int);
            dt.Columns.Add(dc);

            DataColumn dc1 = new DataColumn();
            dc1.ColumnName = "name";
            dc1.DataType = typeof(string);
            dt.Columns.Add(dc1);

            DataColumn dc2 = new DataColumn();
            dc2.ColumnName = "pid";
            dc2.DataType = typeof(int);
            dt.Columns.Add(dc2);

            DataRow dr = dt.NewRow();
            dr[0] = 0;
            dr[1] = "Hello & Goodbye";
            dr[2] = DBNull.Value;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            dr[0] = 1;
            dr[1] = @"&C:\";
            dr[2] = 0;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            dr[0] = 2;
            dr[1] = @"&D:\";
            dr[2] = 0;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            dr[0] = 3;
            dr[1] = "&Program Files";
            dr[2] = 1;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            dr[0] = 4;
            dr[1] = "M&icrosoft";
            dr[2] = 3;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            dr[0] = 5;
            dr[1] = "&Telerik";
            dr[2] = 3;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            dr[0] = 6;
            dr[1] = "&WINDOWS";
            dr[2] = 1;
            dt.Rows.Add(dr);

            return dt;
        }

Workaround: set the DefaultTreeView before subscribing to the treeview events.

            this.radBreadCrumb1.DefaultTreeView = this.radTreeView1;
            this.radTreeView1.NodeFormatting += radTreeView1_NodeFormatting;
            this.radTreeView1.SelectedNodeChanged += radTreeView1_SelectedNodeChanged;
0 comments