Пример #1
0
        private void checkBoxEnableDatabinding_CheckedChanged(object sender, System.EventArgs e)
        {
            if (nChartControl1 == null)
            {
                return;
            }

            NDataBindingManager dataBindingManager = nChartControl1.DataBindingManager;

            dataBindingManager.EnableDataBinding = checkBoxEnableDatabinding.Checked;
            dataBindingManager.UpdateChartControl();
        }
Пример #2
0
        public override void Initialize()
        {
            base.Initialize();

            // add a label
            NLabel title = nChartControl1.Labels.AddHeader("Binding to DataAdapter");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            title.ContentAlignment    = ContentAlignment.BottomCenter;
            title.Location            = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));

            NChart chart = nChartControl1.Charts[0];

            // add the bar series
            NBarSeries bar = new NBarSeries();

            chart.Series.Add(bar);
            bar.Name                  = "Bar";
            bar.Legend.Format         = "<label>";
            bar.DataLabelStyle.Format = "<label>";
            bar.BarShape              = BarShape.SmoothEdgeBar;
            bar.Legend.Mode           = SeriesLegendMode.DataPoints;

            // connection string with relative path
            this.oleDbConnection1.ConnectionString = @"Data Source=""" + Application.StartupPath + @"\..\..\DataManipulation\DataBinding\Data.mdb"";Provider=""Microsoft.Jet.OLEDB.4.0"";";

            try
            {
                NDataBindingManager dataBindingManager = nChartControl1.DataBindingManager;

                dataBindingManager.AddBinding(0, 0, "Values", oleDbDataAdapter1, "values");
                dataBindingManager.AddBinding(0, 0, "Labels", oleDbDataAdapter1, "colors");
                dataBindingManager.AddBinding(0, 0, "FillStyles", oleDbDataAdapter1, "colors");
                dataBindingManager.UpdateChartControl();

                oleDbDataAdapter1.Fill(dataSet1);

                DataTable dataTable = dataSet1.Tables[0];
                dataTable.Columns["id"].ReadOnly = true;
                dataTable.RowChanged            += new DataRowChangeEventHandler(dataTable_RowChanged);

                dataView1.Table = dataTable;
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message);
            }
        }