473,378 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

C# forms query

Hi i'm pretty new to using Visual Studio C#. I am creating an EPOS system for an off license and at the moment I am climatizing myself to using Windows Forms.

This is how I plan for it to be set up:

I have created a main form. On the left hand side there are two group boxes one on top of the other. On the right hand side I am leaving it as a big blank square. The top left box lists the items scanned in with their prices. The bottom left box has buttons for example 'Total', 'Void Sale', 'No Sale' etc. What I am planning is that every screen on the EPOS uses this main form and has its own separate controls in the big blank square on the right.

The stage I am at now is creating the log in screen and so I have hit Add New Item and chosen 'Inherited Form' (choosing the default main form to inherit from). This inherited form is called Login and has the same layout as the main form as I had hoped. Now I have added my log in controls into the big blank square on the right but when I hit run to test the app, all it shows is the original main form with the big blank square and not the log in controls.

Can someone please point me out where I have gone wrong. Maybe I'm not understanding the inherited form option correctly?

Thanks
Jul 30 '08 #1
15 1931
Plater
7,872 Expert 4TB
In your Program.cs file, there will be a section with the line Application.Run(...)
Whatever form is in that ( ) will be the form that runs at program startup. It's probably your "template" form since it was the first one added to the project.
Jul 30 '08 #2
Yeh that's what it shows, but my login form has the following setup:

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Data.SqlClient;
  9. using System.Configuration;
  10.  
  11. namespace EposSystem
  12. {
  13.     public partial class Login : EposSystem.Form1
  14.     {
  15.         public Login()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void btnLogin_Click(object sender, EventArgs e)
  21.         {
  22.             //login script.....
  23.         }
  24. }
  25.  
  26.  
How do I get the form to display the user controls and login button
Jul 30 '08 #3
Plater
7,872 Expert 4TB
So if you make the line be this:
Application.Run(new Login());

It still does not work?
Jul 30 '08 #4
For some reason it now displays the main form with the blank grey square on the right, and then when I hit close, it closes it and opens the login form, can you think of why that may be?

Should I be just use one form for the whole application and just change the visiblity settings for the controls for the user to change between screens?
Jul 30 '08 #5
Plater
7,872 Expert 4TB
That sounds like you have this in your Program.cs file:
Expand|Select|Wrap|Line Numbers
  1. Application.Run(new Form1());//get rid of this line
  2. Application.Run(new Login());
  3.  
Jul 30 '08 #6
lol sorry just realised that id been playing about with the login procedure and forgot to take a line out, thanks for the help, for now......
Jul 30 '08 #7
ok, i've kinda hit a brick wall here. Do you think it's best to use just one form for this whole application and have containers which contain user controls and just hide them and make them visible according to user selection? For example a user logs in, and the login container becomes hidden and the main categories screen becomes visible?

This would be hard to design as I would be creating a large number of containers on top of each other. Would there be any other way round this?

Thanks
Jul 30 '08 #8
Plater
7,872 Expert 4TB
You can add a Form to another Form, that might make it more usefull to you?
Jul 30 '08 #9
how do I do that? Do I just create a form the size of the blank space ? How do I insert it into the parent form
Jul 30 '08 #10
Plater
7,872 Expert 4TB
how do I do that? Do I just create a form the size of the blank space ? How do I insert it into the parent form
There's a setting or two that has to be done on the forms that I can't think of off hand. but it's roughly the same as adding a control to the form (since Form inherits from Control as well)
Jul 30 '08 #11
still havent managed to work out what to do here. Am trying to embed a form within a form and can see no way of doing it - Please help!
Jul 31 '08 #12
r035198x
13,262 8TB
still havent managed to work out what to do here. Am trying to embed a form within a form and can see no way of doing it - Please help!
Step back a bit and start designing your interface again. Draw some flow diagrams if you have to. Each control you put should ideally have a well defined and specific job. If you have to put things on top of another control, use a panel rather than a form.
Jul 31 '08 #13
Thats the problem that I am having. I have one main form and on the right half of it is where new controls appear. The left half stays static and data appears on it as users navigate through the panels on the right. I'm just wondering how I am meant to design multiple panels for one blank space on the form.

The idea is that the user login panel appears in the blank space, and then when a successfull login happens, this login panel dissappears and the main category buttons appear in a panel in its place. I am wondering how to design multiple panels that are going into the same spot.
Jul 31 '08 #14
r035198x
13,262 8TB
CardLayout is what you want. There are several implementations for it like the one I gave there.
I'd keep the Log in screens separate from the rest of the application screens though.
Jul 31 '08 #15
Plater
7,872 Expert 4TB
Seems like you could do this with a TabControl, and just turn the tabbar off in the settings.
Then just switch in between them progmatically
Jul 31 '08 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Nicolae Fieraru | last post by:
Hi All, I want to find if there is a different way than the way I am working now. Lets say I have a table, tblCustomers containing address details. I want a report with all the customers from...
4
by: Lumpierbritches | last post by:
Thank you once again for any and all assistance. I'm building an application that's getting quite bulky due to the number of forms, macros and procedures. I was wondering if there's a way to use 1...
1
by: Andy | last post by:
Hello everybody I have a question on running queries via a form. My situation is – I have a query (qrysearch) and this query has a number of fields e.g. (company, employee etc). My form is...
0
by: John Phelan | last post by:
I had a very large number of query statements that I had converted to SQL a long time ago aticipating that I would some day upsize my application. Every now and then when I do an import to a new...
4
by: Luisa Lopes | last post by:
Dear colleagues: I read somewhere that you could obtain the results of a query as a form. I have design a database for my books and waht I would like is to obtain the results of my queries...
1
by: Raposa Velha | last post by:
Olá Luisa ;-) If I understood correctly, you would like to display the results of a query in a form. No problem, just go to the "Create form by using wizard" and at the first step just choose...
6
by: someguy | last post by:
Hi, I'm trying to accomplish the following on a form on which i have removed navigational buttons (I apologize in advance if this is too many questions); The two easy ones are.... 1) When...
8
by: Zlatko Matić | last post by:
Hello. How can I synchronize subforms content with current record in master form, if both form and subform are based on DAO code ? I assigned DAO recordset to forms by using QueryDef, on Load...
2
by: stoppal | last post by:
I have the following query SELECT TOP 1 CDate(forms!frm_a!cbo_period & '/1/' & forms!frm_a!cbo_year) AS mydate, * FROM DBO_table WHERE DBO_table.field1=forms!frm_a!cbo_field1 And...
2
by: deekay | last post by:
Im trying to update a database where our users have been entering/editing all data using queries to now use forms instead. The first step that I want to take is to convert the queries to forms in...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.