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

C#

 
AnswerRe: My variables content appear in hexadecimal Pin
Bert delaVega30-Jul-07 6:12
Bert delaVega30-Jul-07 6:12 
GeneralRe: My variables content appear in hexadecimal Pin
gapfulgence30-Jul-07 6:52
gapfulgence30-Jul-07 6:52 
QuestionSharp Develop Regular Expression Pin
xawsccs30-Jul-07 5:38
xawsccs30-Jul-07 5:38 
AnswerRe: Sharp Develop Regular Expression Pin
led mike30-Jul-07 5:49
led mike30-Jul-07 5:49 
AnswerRe: Sharp Develop Regular Expression Pin
Martin#30-Jul-07 6:00
Martin#30-Jul-07 6:00 
GeneralRe: Sharp Develop Regular Expression Pin
xawsccs31-Jul-07 6:25
xawsccs31-Jul-07 6:25 
AnswerRe: Sharp Develop Regular Expression Pin
Paul Conrad30-Jul-07 6:22
professionalPaul Conrad30-Jul-07 6:22 
QuestionAccess to the class variable in the Program.cs Pin
UweOeder30-Jul-07 5:31
professionalUweOeder30-Jul-07 5:31 
Hi
I have an application which runs a login screen before the main program runs.
The login only succees when the user enters the right credentials.

The login screen is loaded to show as a dialog. When it closes the main class is run which is tha actual application. I need to access a property which I created in the Login screen's class, in the form_load event of the main class.
However I cannot access the variable which is declared in the Program.cs which is used to load the login screen. It keeps telling me : "The name 'frmTheLogin' does not exist in the current context"

Here the Program.cs code :

namespace ChequeApp
{
static class Program
{
///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
frmLogin frmTheLogin;

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

frmTheLogin = new frmLogin();

if (frmTheLogin.ShowDialog() == DialogResult.OK)
{
Application.Run(new frmChequeApp());
}

}
}
}



Here the Login class code :

namespace ChequeApp
{
public partial class frmLogin : Form
{
private string strUsername; //private variable for username.
IntPtr iptrTheToken;
private Int32 intAccessRight;


//Read-only property for username.
public string Username
{
get
{
return strUsername;
}
}

//Read-only property for the access rights.
public Int32 AccessRight
{
get
{
return intAccessRight;
}
}
...
}



Here the main class code :

namespace ChequeApp
{
public partial class frmChequeApp : Form
{
private string strUsername;
private Int32 intAccessRight;

private System.Windows.Forms.UserControl ctrlChequeApp;


public frmChequeApp()
{
InitializeComponent();
}

private void DisposeControl()
{
if (ctrlChequeApp != null)
{
this.Controls.Remove(ctrlChequeApp);
ctrlChequeApp.Dispose();
ctrlChequeApp = null;
}
}

private void ShowControl()
{
ctrlChequeApp.Location = new Point(1, 1);
this.Controls.Add(ctrlChequeApp);
ctrlChequeApp.BringToFront();
ctrlChequeApp.Dock = DockStyle.Fill;
}

private void frmChequeApp_Load(object sender, EventArgs e)
{
strUsername = frmTheLogin.Username; //IT ERRORS HERE
intAccessRight = frmTheLogin.AccessRight; //IT ERRORS HERE
}
...
}
AnswerRe: Access to the class variable in the Program.cs Pin
led mike30-Jul-07 5:47
led mike30-Jul-07 5:47 
AnswerRe: Access to the class variable in the Program.cs Pin
PhilDanger30-Jul-07 6:05
PhilDanger30-Jul-07 6:05 
GeneralRe: Access to the class variable in the Program.cs Pin
UweOeder30-Jul-07 21:00
professionalUweOeder30-Jul-07 21:00 
QuestionDataGridView Max Rows Pin
jasper01830-Jul-07 5:22
jasper01830-Jul-07 5:22 
AnswerRe: DataGridView Max Rows Pin
led mike30-Jul-07 5:26
led mike30-Jul-07 5:26 
QuestionC# Prep Statement doesn't insert string Pin
NRworld30-Jul-07 4:43
NRworld30-Jul-07 4:43 
AnswerRe: C# Prep Statement doesn't insert string Pin
Pete O'Hanlon30-Jul-07 9:49
mvePete O'Hanlon30-Jul-07 9:49 
GeneralRe: C# Prep Statement doesn't insert string Pin
PIEBALDconsult30-Jul-07 11:23
mvePIEBALDconsult30-Jul-07 11:23 
Questioncomand line Pin
ankit_mait30-Jul-07 4:30
ankit_mait30-Jul-07 4:30 
AnswerRe: comand line Pin
CPallini30-Jul-07 4:38
mveCPallini30-Jul-07 4:38 
QuestionIs there a way to disable "Close" button on title bar? Pin
Tesic Goran30-Jul-07 4:21
professionalTesic Goran30-Jul-07 4:21 
AnswerRe: Is there a way to disable "Close" button on title bar? Pin
originSH30-Jul-07 4:52
originSH30-Jul-07 4:52 
GeneralRe: Is there a way to disable "Close" button on title bar? [modified] Pin
Tesic Goran30-Jul-07 5:02
professionalTesic Goran30-Jul-07 5:02 
GeneralRe: Is there a way to disable "Close" button on title bar? Pin
originSH30-Jul-07 5:20
originSH30-Jul-07 5:20 
GeneralRe: Is there a way to disable "Close" button on title bar? Pin
Tesic Goran30-Jul-07 5:47
professionalTesic Goran30-Jul-07 5:47 
GeneralRe: Is there a way to disable "Close" button on title bar? Pin
originSH30-Jul-07 6:08
originSH30-Jul-07 6:08 
GeneralRe: Is there a way to disable "Close" button on title bar? Pin
PIEBALDconsult30-Jul-07 11:25
mvePIEBALDconsult30-Jul-07 11:25 

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.