|
Hi guys, This is what I am trying to do. Basically, I have a couple of data and I want to insert them into specific positions in a rich text box. Now i am able to copy the data onto the clipboard. the next step is to be able to move the caret to the specified index position and then be able to paste the data from the clip board. my question is, how do i make the caret to move to the specified index position.
thanks
Nana
|
|
|
|
|
There's a selectedText property, from memory. Whatever it is, you set the selected text to be the position you want, and a length of 0. This places the caret where you want it, without selecting anything.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
You are looking for the SelectionStart[^] property. Like Chris said, set SelectionLength to 0 and set SelectionStart to the caret position.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Please excuse me if im way off here, but I will try to communicate my goals well.
I have taken 1 class in C# and I am super green at it. I am attempting to create a database that several people in the US would have access to. We tried MS Access, but as you know it is a bit slow. I would like to create something a little faster. Im not only doing it to help myself and coworkers, but for the learning experience also.
To put it simply, the database I have in mind would simply consist of a form where we could enter information in several fields, and be able to retrieve it later... thats what a database is. My goal is to have the program access a simple txt file stored on a local drive that the program would access to get the information. I say a txt file, because this is all I was taught, and it was very basic. It was also stored on the local PC so the path name was simple.
Are there any suggestion to where I should start. Any good books, or source code I could get and manipulate.
Thanks for your time.
|
|
|
|
|
If it was me, I would use MySQL instead of a text file. It is free and open source (not that you would make changes to the underlying database engine) and there are plenty of administrative tools that are easy to use. Load the engine, create your tables and go.
On the C# side just create a dataset that reflects your database, populate the dataset at runtime, bind your dataset to your webform or windows form and enjoy the hours the microsoft people put in to make your life easy.
As far as references, I went to half price books and got an ADO.NET book, that is your best bet.
|
|
|
|
|
Use SQL Server Express or MSDE. They are free, and unlike MySQL they are free for commercial use, and they are not crap. Plus there is tons of info on the web on how to use them ( any info on connecting to SQL Server will work ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Im a bigtime newb, so I have a few questions. Will either one of these software packages provide me with the tools I need to create an interface with user, so they can add and retrieve data from the database. And a simple way to create a place to store the data. I know Im asking a lot here, I think I need to get some documentation. Any good sites?
|
|
|
|
|
frankie123 wrote: Will either one of these software packages provide me with the tools I need to create an interface with user, so they can add and retrieve data from the database.
No. You're asking in the C# forum, and you can use C# to build an interface. If you want everything done for you in a WYSIWYG fashion, then Access is definately the answer. If you were going to read a flat text file in code, then MSDE is a far better solution.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I am trying to impersonate a user to access a password protected network shared resource. (i.e Start>>Run>>"machine name", then enter user name and password) I am using Win2K. I know that the LogonUser doesn't work on Win2k unless the "Act as part of the operating system" priviledge is set. But that is not an option. I think I might need to use SSPI, but am unsure how to. Here is the code, but because I didn't set the "Act as part of the operating system" priviledge, I get the following error: ERROR_PRIVILEGE_NOT_HELD
1314
[DllImport("advapi32.DLL", SetLastError = true)]
public static extern int LogonUser(
string lpszUsername,
string lpszDomain,
string lpszPassword,
int dwLogonType,
int dwLogonProvider,
out IntPtr phToken);
private const int LOGON32_LOGON_INTERACTIVE = 2;
private const int LOGON32_PROVIDER_DEFAULT = 0;
private void ImpersonateValidUser(string userName, string domain, string password )
{
IntPtr iToken = new IntPtr(0);
try
{
iToken = IntPtr.Zero;
if (LogonUser(@userName, domain, password,
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT,
out iToken) != 0)
{
WindowsIdentity id = new WindowsIdentity(iToken);
// Begin impersonation
impersonationContext = id.Impersonate();
RevertToSelf();
}
else
{
int ret = Marshal.GetLastWin32Error();
}
}
catch
{}
}
How do I use Windows Impersonation on Win2K and not set the "Act as part of the operating system" priviledge?
Any help would be greatly appreciated.
Thanks in advance!
|
|
|
|
|
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
|
|
|
|