|
Or tell me how to get windows username
Thanks and regards,
VijayaRam
|
|
|
|
|
you can use System.Environment.UserName
|
|
|
|
|
It isnt possible to get the user password, however you can validate it using the follow api call
const int LOGON32_LOGON_INTERACTIVE = 2;
const int LOGON32_PROVIDER_DEFAULT = 0;
[DllImport("advapi32.dll", SetLastError=true)]
private static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
private void DoLogonCheck(string userName, string domainName, string password)
{
IntPtr phToken = IntPtr.Zero;
bool logonRes = LogonUser(
userName,
domainName,
password,
LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT,
ref phToken);
if (logonRes)
{
Console.WriteLine("Good logon with username : {0}", userName)
}
else
{
Console.WriteLine("Bad logon with username : {0}", userName)
}
}
I use a similar piece of code to validate that the user true user is sat in front of the machine and not that they have left it unlocked.
|
|
|
|
|
Hi everyone.
One month ago I try to search how to get image from RichTextBox,
But there is no answer.
Please help me how to get image from RichTextBox
Thank You.
Sorry for bad English
|
|
|
|
|
|
Hi
I'm building a little "search" function for my listbox! This is what i want to happend: I got a textbox, then i write the number (the listbox contains a list of numbers) i want to find. The number i write in the textbox should then get selected in the listbox when i click a button. That far, it works great with this code:
lstlistBox1.SelectedItem = txttextBox1.Text;
Now to the problem. If the number i write in the textbox exists more than one time in the list, i want all the items with that name to get selected. Been trying with loops and stuff to make it happend but just wont work. Anyone got a suggestion?
Thx in advance
Light is faster than sound... Thats why some people look smart till they start to talk.
|
|
|
|
|
Iterate over the listbox items and use the SetSelect method to select or deselect the items according to the number in the textbox.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
think you could explain how i do that or add a code sample? Would appreciate it.
Thanks
Light is faster than sound... Thats why some people look smart till they start to talk.
|
|
|
|
|
Hai do the following:
//Add a button and add the following code to that
{
listBox1.SelectionMode = SelectionMode.MultiExtended;
string strSearch = textBox1.Text;
for (int i = 0,j=0; i < listBox1.Items.Count; i++)
{
if (listBox1.Items[i].ToString() == strSearch)
listBox1.SetSelected(i, true);
else
listBox1.SetSelected(i, false);
}
}
Add a textbox and a listbox and try to execute.
regards,
VijayaRam
|
|
|
|
|
Good one, worked on first try Thanks!
Next part of the application is to make another listbox select the same indexes as the first one does, heres also the problem that it only selects one. (note: the same indexes, not the same numbers )
Any suggestions?
Light is faster than sound... Thats why some people look smart till they start to talk.
|
|
|
|
|
Did you even try to understand why and how the code snippet you were given solved your original problem? I doubt that cause otherwise, you would know how to easily solve this one.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Yes, a "make my homework, so I don't have to think!" message board is missing!
|
|
|
|
|
Martin# wrote: Yes, a "make my homework, so I don't have to think!" message board is missing!
Not asking anyone to "make my homework", i simply couldn't get it working... Tried understanding it, tried to get it work and i couldn't, thats why i asked.
Light is faster than sound... Thats why some people look smart till they start to talk.
|
|
|
|
|
Don't take it too personal
Tenkyu wrote:
Light is faster than sound... Thats why some people look smart till they start to talk.
Like that one!
|
|
|
|
|
Tenkyu wrote: Tried understanding it, tried to get it work and i couldn't, thats why i asked.
So what exactly don't you understand? The code snippet you were given is quite simple. It iterates over all list items by index, compares each item to the value of the textbox and then makes a call to the SetSelected method passing the the item index and a boolean indicating whether the item should be selected or not.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
For the first i might add that i'm new to programming, it is one of my first projects i'm playin around with, so didn't know what "iterate" the list meant, and i didn't know how to use "SetSelected" method etc, i'm mostly trying my way there but error messages aint very funny.
Anyways thanks for the help, got it all working now i think.
Light is faster than sound... Thats why some people look smart till they start to talk.
|
|
|
|
|
Will this[^] do?
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|
|
Hey
I have an application that has two comboboxes - the first one (type) is bound to a dataset table and shows all the possible types.
I would like the second one to be bound on the type condition for example:
If there where values it could take such saloon, hatchback, coupe etc.
If the user where to say select VW Golf in the type combobox the combobox below would allow them to select saloon or hatchback. Or if the user were to select BMW 3 Series they would be allowed to select saloon or coupe etc.
I have started down the route of using type as a key in two tables and creating a relation between them but come unstuck when I want to add this to a combobox as my solution is more for datagrids.
If any one could point me in the right direction I would be grateful - is it better to do this without binding the second one and just using SQL to select the type based on the type selection?
Cheers
Dan
|
|
|
|
|
Create a DataView that filters the values you want for the second list when the value of the first list changes.
|
|
|
|
|
you can filter seccond combobox's binding source in order to first combo box's selected value.
or you can read this article:
Parent-Child comboboxes[^]
|
|
|
|
|
Good morning,
I've tried searching in Code Projet and even on the web, but couldn't find anything explaining how to design a custom component for me to use in my forms.
I mean, I saw some articles that use some components (like 3D PieChart) but couldn't understand how it was made.
Can anyone help me?
Thanks,
Gustavo
|
|
|
|
|
|
ok, I'll take a look at that
Thanks
|
|
|
|
|
Hello friends!
I'm having a problem with a datagrid bound to a dataset in ASP.Net with C#
In the database I have entered some text like with an carriage return. But the datagrid trims away the carriage returns...
I would like the datagrid to show these three records like this:
Column1......... Column2............ Column3
-------------------------------------------------
...1..................Test1.1........... This is test one
-------------------------------------------------
...2............... Test2.1............. This is test two
....................Test2.2....................... ................
....................Test2.3....................... ................
-------------------------------------------------
...3 ............. Test 3.1.......................................
-------------------------------------------------
Does anywon know the solution for this?
I have tried to put into the database *n* as a seperator, and in the Datagrid1.ItemDataBound I'v replacing the *n* with \n or \r\n, but whats happens is that for item 2 its like this: Test2.1Test2.2Test2.3 but I want this to be on seperate lines but in the same row of course.
(I'v tried to turn on the .Wrap = true for items also... )
Please let me know if anyone have a solution for this.
Thanks
|
|
|
|
|
I want to access .hlp files that is created in Help Workshop with the help of Help provider in C#.Net.
How can i access? or is there any other solution
-- modified at 7:02 Wednesday 31st January, 2007
|
|
|
|