Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 6th, 2008, 10:17 AM
Registered User
 
Join Date: Aug 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default implementing more than one windows in an app

i have the following: my main form in here i call a second one which in turn calls a method
public partial class EntryForm : Form
    {
        //EventClass myEventClass = new EventClass();
        public EntryForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            FireBirdClass firebirdConvert = new FireBirdClass();
            List<string> fireBirdTables = firebirdConvert.HandleFireBirdData();
            fireBirdTables.Sort();
            this.Hide();
            //SqlConvertClass sqlConvert = new SqlConvertClass(fireBirdTables);
            (new SqlConvertClass(fireBirdTables)).ShowDialog();
            this.Show();

            //sqlConvert.FormClosed += new FormClosedEventHandler(sqlConvert_FormClosed);
            //sqlConvert.ShowDialog();
        }
    }

here the code for my second form:
public partial class SqlConvertClass : Form
    {
        public SqlConvertClass() //contructor initializes the object and instantiates it with the new keyword
        {
            InitializeComponent(); //can initialize it with a value here
        }
        // add private fields
        private List<string> fireBirdTables;
        private List<string> convertedTables;

        // add second constructor
        public SqlConvertClass(List<string> sqlTables)
            : this()
        {
            this.fireBirdTables = sqlTables;

            convertedTables = this.ConvertToSQL(fireBirdTables);
        }

        public List<string> ConvertToSQL(List<string> sqlTables) //method this executes but NO form is showing
        {
           // in here i set values to appear in textboxes on this form
           // i also have progress bars on this form
        }
    }
}

can any one help please
thank you
helloise
 
Old November 6th, 2008, 02:11 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Can you please explain your problem more clearly?

Does the second form never show up?

You indicate that you have progress bars. One of the problems with that is that you need to provide some threading in order for the UI thread to update the form while you have other things going on. Perhaps this is part of the problem. Your code is busy doing the conversion so the display is never updated until after your convert code is done.

-Peter
compiledthoughts.com
 
Old November 10th, 2008, 03:09 AM
Registered User
 
Join Date: Aug 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

yes the second form never shows. how do i introduce threads please
thanks
helloise
 
Old November 10th, 2008, 09:03 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You can start by looking into the Background Worker windows forms component. This is specifically designed to assist in simple background processing.

-Peter
compiledthoughts.com
 
Old November 10th, 2008, 12:42 PM
Friend of Wrox
 
Join Date: Sep 2008
Posts: 234
Thanks: 0
Thanked 32 Times in 30 Posts
Default

I would need to see more of the code to be sure, but in your code:

        public SqlConvertClass(List<string> sqlTables)
            : this()
        {
            this.fireBirdTables = sqlTables;

            convertedTables = this.ConvertToSQL(fireBirdTables);

            this.Refresh(); // ADD THIS LINE
        }


Put a breakpoint on the new line I added above to see that you're returning from the code that updates the textboxes. Depending on how that code is written, it is possible to hang the system in the ConvertToSQL() method. The Refresh() should refresh the form and its controls and it should be visible on the screen.

If that fails, try mixing up a potion of crushed bat wings and eye of newt.

Dr. Purdum


Jack Purdum, Ph.D.
Author: Beginning C# 3.0: Introduction to Object Oriented Programming (and 14 other programming texts)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't Debug Windows App? Ron Howerton Visual Studio 2005 5 November 30th, 2007 05:20 PM
Windows Standalone app echovue Visual Basic 2005 Basics 3 March 12th, 2007 03:27 PM
Accessing Windows service from a windows app sajid08 C# 1 October 6th, 2006 10:25 AM
datagrids (windows app) bazookajoe76 C# 0 February 11th, 2005 11:24 AM
links in a windows app jeffruth VB.NET 2002/2003 Basics 1 April 26th, 2004 04:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.