Click here to Skip to main content
16,004,854 members
Home / Discussions / C#
   

C#

 
GeneralRe: The name port does not exit in current context. Pin
Srinu.D15-Oct-07 21:09
Srinu.D15-Oct-07 21:09 
AnswerRe: The name port does not exit in current context. Pin
Guffa15-Oct-07 21:45
Guffa15-Oct-07 21:45 
QuestionPass data between two forms Pin
MumbleB15-Oct-07 20:53
MumbleB15-Oct-07 20:53 
AnswerRe: Pass data between two forms Pin
Giorgi Dalakishvili15-Oct-07 21:10
mentorGiorgi Dalakishvili15-Oct-07 21:10 
AnswerRe: Pass data between two forms Pin
il_masacratore15-Oct-07 21:13
il_masacratore15-Oct-07 21:13 
GeneralRe: Pass data between two forms Pin
MumbleB15-Oct-07 21:50
MumbleB15-Oct-07 21:50 
GeneralRe: Pass data between two forms Pin
Martin#15-Oct-07 22:11
Martin#15-Oct-07 22:11 
AnswerRe: Pass data between two forms Pin
Andrei Ungureanu15-Oct-07 21:23
Andrei Ungureanu15-Oct-07 21:23 
Well, I can see two ways to accomplish what you want.

1) Set the constructor for the main form to receive a string as a parameter and display that string on the form. Something like this.
public partial class Logon : Form
    {
        public Logon()
        {
            InitializeComponent();
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //Validate the Username and Password

            //Create an Instance of the Mainform
            NEF frm = new NEF(textBox1.Text);

            frm.ShowDialog();
            Application.Exit();
        }
    }

public partial class NEF: Form
{
 public NEF(string username)
 {
   lblUserName.Text = username;
 }
}


2) You can set the textBox1 modifiers to public and call the logon form from the main form (that means that in Program.cs, you should set Application.Run(new NEF()). Here is an example

public partial class NEF:Form
{
 public NEF()
 {

 }

 private void FormLoad(object Sender, EventArgs e)
 {
   Logon frm = new Logon();
   if (frm.ShowDialog() == DialogResult.OK)
   {
     this.lblUserName = frm.textBox1.Text;
   }
 }
}

public partial class Logon : Form
    {
        


        public Logon()
        {
            InitializeComponent();
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //Validate the Username and Password
            if (textBox1.Text == "maphanga" && textBox2.Text == "marsha" 
                || textBox1.Text == "nkosi" && textBox2.Text == "mdu" 
                || textBox1.Text == "carrim" && textBox2.Text == "allerece" 
                || textBox1.Text == "raphela" && textBox2.Text == "rachel" 
                || textBox1.Text == "mazibuko" && textBox2.Text == "zoliswa")
            {
                this.DialogResult = DialogResult.OK;
            }
            else MessageBox.Show("Invalid username and or password supplied");
            
            //Label Captures the username from textBox1
            lbluser.Text = textBox1.Text; 
        }
    }


Hope it helps.

There are 10 kinds of people: those who understand binary and those who don't

Questiondatagrid Pin
Trustapple15-Oct-07 20:50
Trustapple15-Oct-07 20:50 
AnswerRe: datagrid Pin
Andrei Ungureanu15-Oct-07 21:31
Andrei Ungureanu15-Oct-07 21:31 
GeneralRe: datagrid Pin
Trustapple15-Oct-07 21:36
Trustapple15-Oct-07 21:36 
QuestionHow can I save printer System.Drawing.Printing.PrintPageEventArgs ??? Pin
galigal1515-Oct-07 20:36
galigal1515-Oct-07 20:36 
AnswerRe: How can I save printer System.Drawing.Printing.PrintPageEventArgs ??? Pin
stancrm15-Oct-07 20:40
stancrm15-Oct-07 20:40 
GeneralRe: How can I save printer System.Drawing.Printing.PrintPageEventArgs ??? Pin
galigal1516-Oct-07 23:00
galigal1516-Oct-07 23:00 
Questionsimple functional overloading [modified] Pin
Trustapple15-Oct-07 20:28
Trustapple15-Oct-07 20:28 
AnswerRe: simple functional overloading Pin
Ajay.k_Singh15-Oct-07 20:53
Ajay.k_Singh15-Oct-07 20:53 
GeneralRe: simple functional overloading Pin
Trustapple15-Oct-07 21:26
Trustapple15-Oct-07 21:26 
QuestionDataset, relationships and keyref Pin
Sydneycan15-Oct-07 20:23
Sydneycan15-Oct-07 20:23 
Questionsocket programming Pin
cyn815-Oct-07 19:25
cyn815-Oct-07 19:25 
AnswerRe: socket programming Pin
Andrei Ungureanu15-Oct-07 19:58
Andrei Ungureanu15-Oct-07 19:58 
QuestionLicense key of MathML .NET Control. Pin
Tuongnd15-Oct-07 19:01
Tuongnd15-Oct-07 19:01 
AnswerRe: License key of MathML .NET Control. Pin
stancrm15-Oct-07 19:06
stancrm15-Oct-07 19:06 
QuestionFunctions Pin
Trustapple15-Oct-07 18:40
Trustapple15-Oct-07 18:40 
AnswerRe: Functions Pin
Abhijit Jana15-Oct-07 18:59
professionalAbhijit Jana15-Oct-07 18:59 
GeneralRe: Functions Pin
Trustapple15-Oct-07 19:53
Trustapple15-Oct-07 19:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.