We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Public variable

Thread ID:





968 Sep 6,2002 04:11 PM UTC Sep 7,2002 06:28 AM UTC WinForms 1
Tags: FAQ
Jassim Rahma
Asked On September 6, 2002 04:11 PM UTC

How can I assign a public variable which is in form A to be available in all forms. Variables are a database variables like user name, password and user group?

Clay Burch [Syncfusion]
Replied On September 7, 2002 06:28 AM UTC

One way you might do this is to add a public static (Shared in VB.Net) member to your class. Then you can access this member from any place in your application using Classname.MemberName. 'VB declaration within the class Form1 Public Shared UserName As String .... 'whereever you need to use it Form1.UserName = "somename" .... If name = Form1.UserName Then .... //declaration in C# public static string UserName;


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon