Click here to Skip to main content
15,896,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
CSS
hey can you explain me how to store username and usertype  info on my windows form application vb.net , according to user logged in my app i want to restrict accessibility  e.g hiding one of tabcontrol and change users password without typing his username in form means: when user logged his username and usertype will be available in my application i want to show his name on each form
help me if you knw
Posted

Hi,

In C# you can create a Class and

public class StateInfo
{
public StateInfo() { }

public static string username { get { return "User1"; } }
}

In your LoginForm
Loginbutton Click
{
StateInfo.username=txtusername.Text;
}

and in other Form_load
{
lblusername.text=StateInfo.username;
}

In VB.Net
You can use the Modules insted of Class rest is same
Public Module StateInfo
Public username As String = ""

End Module

In your LoginForm
Loginbutton Click
{
username=txtusername.Text
}

and in other Form_load
{
lblusername.text=username
}
 
Share this answer
 
Comments
Tarun Jaiswal 29-Sep-14 8:43am    
Hello Mr.syed shanu above example work fine in windows Application.
but now m trying to make WPF application the StateInfo class is not access-able in login button. can you please guide me how i can maintain the userstate in WPF app.
thanks man this solves my problem
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900