Click here to Skip to main content
15,886,840 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#

Hello everyone i really have a issue here. I really need this command here is the issue:

In form 1 i created login form, when login is completed form 3 shows up, there i have some text boxes which i want to write down to database also, but i want to write also user name (email in this case) of user who did this. Not windows name, not name of my computer. Email that i used to log in in form 1 (called 1), to store with these other data which is entered in texboxes. Tried to point it with method but i cant call method from form 1 to form 2. im using 2017 visual studio c# form
Thx in advance

What I have tried:

WindowsIdentity.GetCurrent().Name
Enviroment.Name
Posted
Updated 21-May-17 2:09am
Comments
[no name] 21-May-17 8:12am    
If you wanted to use the value from some textbox on form 1 then why did you write code to use the windows identity? Does that even remotely make sense to you? Why don't you simply pass the data from form 1 to form 2?
Member 13213653 21-May-17 8:19am    
it makes sense. But thats not the point, when i googled this issue i got only this sollution but thats not what i ment. I tried to point but no succsess, get errors every singe code i type. Im kind a noob so, please understand.
[no name] 21-May-17 8:28am    
If it makes sense to you then you have absolutely no idea how computers work or what you are doing. Get yourself a decent book on programming and work through it if you want to be a programmer. Then learn how to ask questions.
Member 13213653 21-May-17 8:26am    
Also i dont want to point it to other text box i want to take it from sistem and when the query is done to type it ti database. I just remembered that i can hide text box and store it there but is there any solution to get it from sistem?
[no name] 21-May-17 8:29am    
No! The system has no idea what the user typed into some random textbox on your form.

1 solution

Maybe the easiest way is to create another project with a static class, e.g. "Person".
public static class Person
{
    public static string FirstName;
    public static string LastName;
    public static string Email;
}
You can then easily refer to Person fields or properties from your forms.

If you don't want to use an extra project, you can also use the default Program class (where your Forms are called) to place the fields or properties you need.
 
Share this answer
 
v2

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