|
Hi,
I need to manage a treeview control with a vertical scrollbar control. I can't use the default scrollbar of the treeview and so I have to disable scrollbars on the treeview and use an external vertical scrollbar. Is this possible?
|
|
|
|
|
Hi guys
How can I delete all occurrences of the word 'test' from a string
I.e. String Before: This is a test to delete all occurrences of the word test
String After: This is a to delete all occurrences of the word
Please give me some guidelines here.
Thanks
R
|
|
|
|
|
You can use split, like this:
string myString = "this is a test waffle";
string temp[] = myString.Split("test ");
myString = "";
foreach(string str in temp) {
myString += str;
}
Then, after all that, your string should be "this is a waffle".
|
|
|
|
|
what you could do is keep it simple
use string.Replace.
ex:
string x = "This is a test,test";
string y = x.Replace("test","");
Console.WriteLine(y);
output should look like "This is a , "
have fun
Kaine
|
|
|
|
|
Damn, string.Replace. How could i forget that. Oh well, time to go methinks.
On a side note, i appear to have found a new forum to live on for a while. Who would have thought it'd be here?
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Thanks to both of you that replied!!
R
|
|
|
|
|
But what if you were to remove a word like '{test}' including the braces?
|
|
|
|
|
Nevermind I got it now, I'm just being stupid today...
Thanks again guys!
|
|
|
|
|
Is there a neater more professional way to re-write the code below?
<br />
public string StripString(string statementString)<br />
{<br />
string alteredStatement = string.Empty;<br />
<br />
string keyword1 = "[dbo].";<br />
string keyword2 = "[";<br />
string keyword3 = "]";<br />
string remover = "";<br />
<br />
string tmpStr1 = statementString.Replace(keyword1, remover);<br />
string tmpStr2 = tmpStr1.Replace(keyword2, remover);<br />
<br />
alteredStatement = tmpStr2.Replace(keyword3, remover);<br />
<br />
return alteredStatement;<br />
}<br />
|
|
|
|
|
Do you mean something like this?
Regex.Replace(statementString, @"\[|dbo].|\]", "");
instead of the function
Greetings
Kaine
|
|
|
|
|
I was thinking of Regex but wasn't sure.
Thanks for that Kain!
|
|
|
|
|
I'm not sure why you're removing the brackets and 'dbo' from SQL. It could open you up to syntax errors, especially since you don't account for the context whatsoever in these sort of find/replace methods. Plus, I remember reading somewhere that stating 'dbo' will improve lookup performance
But whatever...just throwing that out there as a word of caution.
|
|
|
|
|
This one is more concise and more efficient since it doesn't create unnecessary temporary string instances.
public string StripString(string statementString)
{
string[] keywords = { "[dbo].", "[", "]" };
StringBuilder result = new StringBuilder(statementString);
foreach (string keyword in keywords) result.Replace(keyword, string.Empty);
return result.ToString();
} Now, let me ask you a question. It appears you're trying to parse a connection string - is that what you're trying to do? Are you aware there's already a class in the .NET framework that parses a connection string and give you back the interesting pieces of information? That would be OdbcConnection; pass a connection string in the constructor and you'll have a connection object containing all the properties of the connection string.
|
|
|
|
|
string s = "this is a test";
s.Replace("test", "");
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi, all replies may lead to damaged sentences such as "Nuclear s damaged the conants inines",
and basically ignore the subject line.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Actually, i think a couple of the replies inlcuded a space after the word test, so "test ". That would only ruin words ending in test.
And besides, if you do it the way i said originally (though of course, i had forgotten about string.replace) you can remove " test "
with spaces either side. And then when you re-build the string, add the spaces back in.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Words are not necessarily surrounded by spaces, there could be punctuation marks too.
This contest holds two "test" words for you to test.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Yar, stupid punctuation, ruined the english language.
I concede to your brilliance.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Hi:
I am looking for a way to assure that only one instance of a WinForm application can be run on a local area network, how should I go about this?
I'm not up to speed with Sockets or UDP communications, so don't really know where to start.
---
Regards,
Martin.
|
|
|
|
|
i think the easyest way is to create a dummy file somewhere on the network (accessable to everybody)
when your app starts.
and delete when app closes.
in startup of your app, check for existens of that file (File.Exists)
Hope this helps
Kaine
|
|
|
|
|
Although of course, evil people could find an delete the file, then run the form when theyre not supposed to!
Depends on your circumstances though. This is definitely a good idea though.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Hmm. I found this topic: http://www.thescripts.com/forum/thread253568.html[^]
Doesn't give much info, but from what i can see you can get remote processes by using:
Process.GetProcesses("remote pc name");
and that you need to have remote access enabled on the rmeote machine, and maybe some other stuff. You might not need to use sockets at all, although they are rather quite simple to use.
So, you'd have to check the processes of each machine individually, and then run your form if you don't find an instance of your form anywhere.
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Hmm, I was thinking more along the lines of a Broadcast or Multicast message and reply workaround.
The created file solution might be a quick & dirty solution though...
---
Regards,
Martin.
|
|
|
|
|
MartinHart wrote: The created file solution
Make sure you (a) create the file if it doesn't already exist and (b) keep it open for exclusive access as long as the app is running.
/ravi
|
|
|
|
|
Good Morning All,
First off, this forum has helped me a great deal with my endeavors of understanding C# better. I utilize the archives and searches extensively and have more times than not found the answer I needed right away.
This time however, I need some help directly. I am creating an application where by I am writing a config file in XML (thanks to a posting here), and one of the elements I need is a directory. I have found and am utilizing the OpenFileDialogue but this Dialogue Box will not allow me to select a directory only. Is there another object that will allow the user to select a directory.
I don't want the user to type in the directory, as you can imagine, just using the Dialogue Box would aleviate users anticipations.
Any help would be greatly appreciated.
|
|
|
|