Dynamic Filtering of Chart Using a Combobox C#

  • Thread starter Thread starter Jazmin25
  • Start date Start date
J

Jazmin25

Guest
Hi All, I am currently learning how to program using Visual Studio C# and I am struggling to filter a chart using a combobox select values. I have created an ADO model that allows me to feed the Chart/graph. The problem is that this model is Static and can only allow me to choose 2 established fields that represent that Y and X axis. It only allows me to input specific field field names( example: productName, or Age). What I would like is the ability to have a dynamic code where I am using a combobox.Text or combobox.SelectedItem.ToString parameters instead of specifying a field name from the model. I would therefore have 2 comboboxes containing all field names of a specific table, the first used as the X Axis and the second as Y axis. This means, I would be able to choose one combobox value as the X axis and another as a Y axis to represent different fields of a table. I cant manage to get it done despite using combobox.Text as a parameter and others. Below is my code, can anyone point help me please?



using (csc8008Entities4 ddb = new csc8008Entities4()) // model name
{
Fchart1.DataSource = ddb.products.ToList();

Fchart1.Series["Gen View"].XValueMember = "productID";
Fchart1.Series["Gen View"].XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Int32;
Fchart1.Series["Gen View"].YValueMembers = "price";
Fchart1.Series["Gen View"].YValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;


}

Continue reading...
 
Back
Top