Page 1 of 1

Getting tables from dataset

Posted: Wed Feb 23, 2011 7:32 pm
by 14051412
Hi forum

i have a problem with this fffff components. I have lost my day, trying to solve this, but is not possible. I know i have asked this before, but the problem is still here.

I have a user control in my project.

by code, I have the next

Code: Select all

public class Graph : UserControl
{
        private DataSet _ds;

        pubic Graph(DataSet ds)
        {
           this._ds = ds;

            InitializeComponent();
            MyInit();
        }

        private void MyInit()
        {
            tchart1 = new TChart();
            tchartController1 = new ChartController();

            tchart1.Dock = DockStyle.Fill;
            tchart1.Axes.Left.Automatic = false;
            tchart1.Axes.Left.Maximum = 1;

            tchart1.Axes.Bottom.Automatic = false;
            tchart1.Axes.Bottom.Maximum = 1;

            tchartController1.Chart = tchart1;
         
            this.Controls.Add(tchart1);
            this.Controls.Add(tchartController1);
        }
}
Now, I go to the Editor of the chartcontroller, press Add button to add a new serie. Until here, is ok.
Now, I select the new serie a go to tab Series>Datasource and chooses Database as Datasource, but in the dropdownlist dataset i cannot find the tables.

I have tryed all:

with the tutorial "Connecting to ADO.NET sources at run-time"
with singlerecord
with crosstab

, but have been impossible.

what I need is only something like:

tchart.datasource = dataset; or
tchartcontroller.datasource = dataset;

Somebody can tell, whether is possible to get this tables in a comprensible way.

Thankyou

Re: Getting tables from dataset

Posted: Thu Feb 24, 2011 11:36 am
by 10050769
Hello lolo,

If you use Winforms as host of your User control, you need create DataSet in WinForms project, if you want this works correctly. You can do something as next example:
Host project WinForms code :

Code: Select all

       public Form1()
       {
            InitializeComponent();
            InitializeOther();
       }

    private UserControl1 control;
    private DataSet ds;
    private void InitializeOther()
    {
       ds = new DataSet();
       control = new UserControl1();
       control.Dock = DockStyle.Fill;
       Controls.Add(control);
    }
User Control form code:

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        Steema.TeeChart.TChart tchart1;
        Steema.TeeChart.ChartController tchartController1;
        private DataSet ds;
        private void InitializeChart()
        {
            tchart1 = new Steema.TeeChart.TChart();
            tchartController1 = new Steema.TeeChart.ChartController();
            tchart1.Dock = DockStyle.Fill;
            tchart1.Axes.Left.Automatic = false;
            tchart1.Axes.Left.Maximum = 1;

            tchart1.Axes.Bottom.Automatic = false;
            tchart1.Axes.Bottom.Maximum = 1;

            tchartController1.Chart = tchart1;

            this.Controls.Add(tchart1);
            this.Controls.Add(tchartController1);
        }
Could you confirm us if previous code works as you want?

I hope will helps.

Thanks,

Re: Getting tables from dataset

Posted: Fri Feb 25, 2011 9:21 am
by 14051412
Hi Sandra

Thank you very much.

I have tested this code and works perfectly.

Thanks again.