Closing Form

Stimulsoft Reports.NET discussion
Post Reply
jjc
Posts: 97
Joined: Mon Apr 19, 2010 10:14 pm

Closing Form

Post by jjc »

Hi all,
when i close a StiForm to exit i noted the report begin to compile all records present in Database ,
How i can avoid this feature?

Thanks so much.

Have a good time.

Cheers
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Closing Form

Post by Alex K. »

Hello,

You can set properties "Connect on Start" on DataSource to false.

Thank you.
jjc
Posts: 97
Joined: Mon Apr 19, 2010 10:14 pm

Closing Form

Post by jjc »

Hi Aleksey ,thanks for your reply,

You can set properties "Connect on Start" on DataSource to false.
i tried to set properties "Connect on Start" on DataSource to false but when i need to choose the data to send to the report in the listboxs did not appear anything.

How i can work out this step?

Thanks so much for your advice.

have a good day.

Cheers



Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Closing Form

Post by Alex K. »

Hello,

If you set the "Connect on Start" to false, then, in this case, you need to obtain data for the forms manually.
For example:

Code: Select all

foreach (DataRow row in DataSource.Rows)
{
	ListBoxControl1.Item.Add(row["ColumnName"]);
}
Thank you.
jjc
Posts: 97
Joined: Mon Apr 19, 2010 10:14 pm

Closing Form

Post by jjc »

Hi Aleksey,
i set properties "Connect on Start" on DataSource to false(in this case City_TBL)
after in the form i inster this code to fill the ChecklistBox from City_TBL :

Code: Select all

if (ComboBoxControl1.SelectedIndex >= 0)
{
string index = Country_TBL.GetData("CountryCode", ComboBoxControl1.SelectedIndex).ToString();

   	CheckedListBoxControl1.Control.Items.Clear();
	City_TBL.First();

	while (!City_TBL.IsEof)
	{
		if (City_TBL.CountryCode == index)
		{
              foreach(DataRow row in City_TBL.Rows)
              {
			 CheckedListBoxControl1.Control.Items.Add(row["CityCode"]);}
               }
	   City_TBL.Next();
	}
}

and when i click the button to load the data i receive this exception:
Unable to cast object of type "Stimulsof.Report.Dictionary.StiRow" to type "System.Data.DataRow".


Do i right the code or there is some error?

Thanks so much for your attention.

Have a good time.

Cheers
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Closing Form

Post by Alex K. »

Hello,

Modify your code:

Code: Select all

if (ComboBoxControl1.SelectedIndex >= 0)
{
    string index = Country_TBL.GetData("CountryCode", ComboBoxControl1.SelectedIndex).ToString();

    CheckedListBoxControl1.Control.Items.Clear();
    City_TBL.First();

    while (!City_TBL.IsEof)
    {
        if (City_TBL.CountryCode == index)
        {
              foreach(Stimulsoft.Report.Dictionary.StiRow row in City_TBL.Rows)
              {
                   CheckedListBoxControl1.Items.Add(row["CityCode"].ToString());
              }
         }
         City_TBL.Next();
     }
}
Thank you.
jjc
Posts: 97
Joined: Mon Apr 19, 2010 10:14 pm

Closing Form

Post by jjc »

Hi Aleksey,
i tried to correct the code as you post before but when did not load the data from the database.
I am so sorry for my bother however i am trying another solution too to work out this issue.

Thanks for your help.

Have a good day.

Cheers
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Closing Form

Post by Alex K. »

Hello,

Sorry. Add also in this code:
City_TBL.Connect();

Thank you.
Post Reply