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
close icon

Public variable

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?

1 Reply

CB Clay Burch Syncfusion Team 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;

Loader.
Live Chat Icon For mobile
Up arrow icon