RadDropDownList & RadChartView Question..

1 Answer 55 Views
ChartView DropDownList
arbam
Top achievements
Rank 1
Iron
arbam asked on 11 Aug 2022, 01:43 PM
1) RadDropDownList (cbo.png)
Currently, only text is displayed on the display member.
But I want to show both Code and Name.

2) RadChartView (chart.png)
The data table to apply to the chart on the left.
Currently, I applied the data table to the DataSource in the chart, and I applied it like CategoryMember="name" / ValueMember="value" / DisplayMember="code".
However, I want to show the name on the x-axis and have the code, and I want to show the value on the Labels (Display Member).

Is there a way?

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 12 Aug 2022, 05:49 AM
Hello, Arbam,   


I will go straight to your questions:

1. When using data binding for populating RadDropDownList with data, note that the DisplayMember property allows you to specify the particular field in the data source which will be used from the items in RadDropDownList for their Text. It is possible to specify only a single field. Creating a property that combines multiple fields (e.g. CODE + NAME) is the appropriate approach for displaying more than one field. It is just necessary to set that combined field as DisplayMember. Alternatively, you can subscribe to the VisualListItemFormatting event and set the VisualItem.Text to the desired combined text extracted from the DataBoundItem. The following forum thread is quites useful on this topic:
https://www.telerik.com/forums/multiple-field-displaymember

2. RadChartView supports ChartSelectionController that makes your charts more interactive by adding a selection behavior. Thus, you can detect which data point is selected and extract the associated DataItem which give you access to the Code: 

        public RadForm1()
        {
            InitializeComponent();

            DataTable dt = new DataTable();
            dt.Columns.Add("Code", typeof(int));
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Value", typeof(int));

            dt.Rows.Add(123, "Name1", 10);
            dt.Rows.Add(456, "Name2", 20);
            dt.Rows.Add(789, "Name3", 30);

            BarSeries bs = new BarSeries();
            bs.ShowLabels = true;
            radChartView1.Series.Add(bs);
            bs.ValueMember = "Value";
            bs.CategoryMember = "Name";
            bs.DataSource = dt;

            radChartView1.Controllers.Add(new ChartSelectionController());
            radChartView1.SelectionMode = ChartSelectionMode.SingleDataPoint;
            radChartView1.SelectedPointChanged += new ChartViewSelectedChangedEventHandler(radChartView1_SelectedPointChanged);
        }

        private void radChartView1_SelectedPointChanged(object sender, ChartViewSelectedPointChangedEventArgs e)
        {
            DataRowView rowView = e.NewSelectedPoint.DataItem as DataRowView;
            string code = rowView.Row["Code"].ToString();
            this.Text = "Code: " + code;
        }

I would kindly ask you to open a separate thread with the appropriate Product (RadDropDownList for WinForms) and to avoid mixing different subjects in the same thread in future. This will also give you the opportunity to track the different cases easily in your account.

Thank you for your understanding.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
ChartView DropDownList
Asked by
arbam
Top achievements
Rank 1
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or