|
Hello,
Is there a way of getting a current user logged on the machine?
Thank you.
|
|
|
|
|
using System.Threading;
using System.Security.Principal;
using System.Security.Permissions;
class xxyxyx{
Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
}
Include these two lines in your code. Then in Thread.CurrentPrinciple.Identity will have ur username.
|
|
|
|
|
|
After those two lines you can use this anywhere in the scope of that code.
Thread.CurrentPrincipal.Identity.Name
will give u the user name
|
|
|
|
|
Environment.UserName
If you just want to know which user started your process.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
Ths link is taking me to a "post message" page, please resend the problem
|
|
|
|
|
Hi, yeah! Heres the problem.
Ive posted on this board before but in the Visual C++ area.
My Question is :
In my previous questions, I created a new EditBox Class Called CInitials
and changed the OnChar Message to append a '.' after each keypress.
The code for that was done like this:
void CInitials::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
//** Validate the entered character
if (isalpha(nChar) )
{
// ** Convert lower to to UPPER case
if ( islower(nCHAR) )
nChar -=32;
// ** Call the default windows procedure as
// ** the value of the nChar may have been altered
DefWindowProc(WM_CHAR, nChar,
MAKELONG(nRepCnt, nFlags));
// ** Call the default windows procedure
// ** again to add the period.
nChar = '.';
DefWindowProc(WM_CHAR, nChar,
MAKELONG(nRepCnt, nFlags));
}
// ** If the backspace key is pressed call the
// ** base class function twice to remove the period
// ** and the letter
if ( nChar == VK_BACK )
{
CEdit::OnChar(nChar,nRepCnt,nFlags);
CEdit::OnChar(nChar,nRepCnt,nFlags);
}
}
The CInitials Class was derived from the CEdit Class in Visual C++.
The question is, can this be done in C#? If yes how?
Thanks again
Tom
|
|
|
|
|
Is there a way to perfectly align the first part of a string on the left side of a combobox and the 2nd part to the right without using a fixed width font? Graphics.MeasureString would allow an approximation by repeatedly adding spaces in between until the string became too long but I assume there would still be some raggedness. THe problem with a fixed width font is that it would look different tham the remainder of our app.
|
|
|
|
|
I want to display filenames+dates in a combo box and sort by date. Is there a way to do it while keeping the dates to the right of the filenames?
|
|
|
|
|
Create a datatable and add the items to it. Then sort the datatable using a dataview and set the datasource of the combobox to the dataview.
|
|
|
|
|
I suppose that would work, but it seems like alot of hoops to be jumping through.
|
|
|
|
|
how are you adding the items to the combo box?
|
|
|
|
|
Iterating an internal datastructure (hash table of wrapped classes generated by the xsd tool), and if the neccesary conditions are met, calling combobox.Items.Add(filename).
|
|
|
|
|
It's the only (and best) way to do it.
Carl Mercier
Geek entrepreneurs, visit my blog! [^]
|
|
|
|
|
Hi guys.Im in desperate need for help.Need some help to find any code for building Control System plots in C#.I mean build such plots as Bode,Nyquist etc.Its very simple to plot them in MAtlab But I have to plot them in C#.Anybody can help me ? Thank you
|
|
|
|
|
I don't know exactly what you want to draw, but you need to draw them yourself. Have you looked into the Graphics namespace ? Basically a Graphics object contains a Bitmap and has methods for drawing on it.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
how can start the compile process without make run the application?
|
|
|
|
|
|
Ctrl + Shift + B
or Alt + B then release both keys and press E
R A M
|
|
|
|
|
Hi,
I'm quite new in the advanced GUI features of .NET . Can anybody tell me how to change the (back/fore)color of a scrollbar in a listbox? Did some research on the net but didn't really find a good answer.
Thanks
Gideon
|
|
|
|
|
Is this for a web based application or a windows applciation? In web based, we can use CSS style sheets to change the style of the scroll bar. In windows application, we do not have any direct means of changing the style of scrollbar. You could write a customized scroll bar that is inherited from windows scrollbar class.
Here is link for it in windows http://www.codeproject.com/vb/net/corescrollbar.asp[^]
|
|
|
|
|
Yes it is for a windows app. I saw the article before, but wasn't sure if there was a better/easier way to do it.
I know how to hide the vertical scrollbar, but how do I make the listbox scroll up or down programmatically?
Thanks,
Gideon
|
|
|
|
|
You can do this. Its a kinda hack but it works. Set the selected index to the item till where you would like to scroll down. Then set it back to -1.
Through this you could control the scroll too. I have tried it and it works.
|
|
|
|
|
Thanks, I will give it a try tomorrow.
Gideon
|
|
|
|