|
Hi,
I am trying to set/get the text of my RichTextBox, but Text is not among list of its properties when I want to get test.Text...
I am using code behind in C# (.net framework 3.5 SP1)
RichTextBox test = new RichTextBox();
cannot have test.Text(?)
Do you know how come it can be possible ?
thanks,
|
|
|
|
|
RichTextBox [^] dont have Text property?!
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
There was a confusion between RichTextBox in System.Windows.Forms and in System.Windows.Control
I am using the one in the Control as I am using WPF. In there, there is no Text property, and in order to get a text, I should have used this line:
string myText = new TextRange(transcriberArea.Document.ContentStart, transcriberArea.Document.ContentEnd).Text;
thanks
|
|
|
|
|
WHY DOEST THIS WORK?
RegistryKey RegKeyWrite = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\SystemRestore");
RegKeyWrite.OpenSubKey("DiskPercent");
RegKeyWrite.("DiskPercent",0);
RegKeyWrite.Close();
|
|
|
|
|
Maybe you don't have permission to edit the registry?
What is the exception being thrown?
|
|
|
|
|
Thank you for your Reply,
No exception is being thrown just trying to set a value to the registry
Guess I'll have to figure out how to give my program permission to set values in the registry
Regards
Rick
|
|
|
|
|
rick0557 wrote: WHY DOEST THIS DIDN'T WORK?
Open regedit.exe
and check if the following reg key exist !
HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\SystemRestore\\
and if it's not , then replace
OpenSubKey with
CreateSubKey
P.S
Always use
CreateSubKey it's try to open the key and if it's not exist then create it .
I know nothing , I know nothing ...
|
|
|
|
|
rick0557 wrote: RegKeyWrite.("DiskPercent",0);
You've not specified a method. SetValue may be relevant
rick0557 wrote: RegKeyWrite.OpenSubKey("DiskPercent");
You should be assigning the result of this invocation to RegKeyWrite
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Registry KEYS are the folders you see in RegEdit.
Registry VALUES are the named items in the folders (Keys).
I think you're looking for something more like:
RegistryKey RegKeyWrite = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\SystemRestore");
RegKeyWrite.SetValue("DiskPercent",0);
RegKeyWrite.Close();
|
|
|
|
|
Thank You for your answer
Tried it but that did change anything either.
Guess I'll have to give my program permission to set values in the registry
Regards
Rick
|
|
|
|
|
You don't give your "program" permissions to the registry. Your application runs as YOU, or the person or ID that launched it. If you don't have permissions to change that value, you have to use a higher level user account, like an Admin account.
If you're running the code under a normal user account, just about the entire HKEY_LOCAL_MACHINE hive is off-limits. If you're code is not just swallowing the exceptions, your code should have thrown an Access Denied error, or something very similar.
|
|
|
|
|
Thank You for your reply,
Got it figured out. just one of those rookie mistakes.
your origional solution was right on the mark.
worked just fine once I got my head around it.
Regards
Rick
|
|
|
|
|
Is there a way to iterate through a string of text and find each occurence of a string that contains a substring of "{" + (variable string) + "}" and replace it with a corresponding string defined in a dictionary (of which the key value is the "{" + (variable string) + "}" ??
|
|
|
|
|
string OldStr = "Application";
string NewStr = "Program";
string str = @"Run the Application , Close the Application and Delete the Application";
str = str.Replace(OldStr, NewStr);
I know nothing , I know nothing ...
|
|
|
|
|
Thanks.. I used that in a loop and put all the key values as the string to be replaced
|
|
|
|
|
Yes.
I suppose you'll want a hint as to how!
If the string is formatted such that { and } only occur as a wrapper to a variable name then the easiest way I can think of is to run a regex on it, match all "\{[^\}]\}" and iterate through them.
If not you'll probably have to write a lexer of some kind.
10110011001111101010101000001000001101001010001010100000100000101000001000111100010110001011001011
|
|
|
|
|
This is a good solution too, thx
|
|
|
|
|
Given that you have the text in the text variable and the replacements in the replacements dictionary:
text = RegEx.Replace(text, @"\{(.+?)\}", m => replacements[m.Value]);
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Can anyone see what I'm doing wrong here?
All I want to do is generate a password with htpasswd.exe and it looked
easy enough but it just gets stuck at ReadLine()
ProcessStartInfo ps = new ProcessStartInfo();
ps.FileName = Path.Combine(Application.StartupPath, "htpasswd.exe");
ps.Arguments = "-n test";
ps.CreateNoWindow = true;
ps.UseShellExecute = false;
ps.RedirectStandardInput = true;
ps.RedirectStandardOutput = true;
ps.RedirectStandardError = true;
Process proc = new Process();
proc.StartInfo = ps;
proc.Start();
proc.StandardInput.WriteLine("testing");
proc.StandardInput.WriteLine("testing");
string line = proc.StandardOutput.ReadLine();
proc.Close();
|
|
|
|
|
I know nothing about 'htpasswd', but generally a ReadLine() method expects a carriage return. Did you hit return?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
The WriteLine adds a carriage return so that part is ok.
I found what I had missed, the command-prompt needed to
exit before it returned the result.
So adding this before reading the output solved it:
proc.StandardInput.WriteLine("exit");
|
|
|
|
|
|
True it generates a sort of md5 hashed passwords, but htpasswd.exe is a part of
Apache webserver and they use a modified version of md5.
|
|
|
|
|
Hi,
My question has two parts:
1) How can I search for a sentence (e.g., Dell Canada) in a string (e.g., I am working in Dell Canada, and I found it...) .
2)The second part is my string is text in a RichTextBox, so I would like to find the TextRange of that selected sentence and apply certain decoration.
thanks.
|
|
|
|
|
+++ AUTOREPLY #17 +++
What have you tried so far?
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|