|
Hi,
you can use regex match to determine its content.
|
|
|
|
|
ThanQ for your response.
Could you please write code for that.
Regards
sekhar
|
|
|
|
|
sekhar.k wrote: Could you please write code for that.
I thought that this was a forum for programmers, not copy-pasters...
if (Regex.Match(str, "^\d+$").Success) ...
^ = start of string
\d = any digit
+ = one or more times
$ = end of string
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
This is my first code :
private void fontToolStripMenuItem_Click(object sender, EventArgs e)
{
fontDialog1.ShowDialog();//display the interface to change font
this.Font= fontDialog1.Font;
}
and the result i get for chaning the font size to 14 is this :
After that, I change the code to this :
private void fontToolStripMenuItem_Click(object sender, EventArgs e)
{
fontDialog1.ShowDialog();//display the interface to change font
btnTest.Font= fontDialog1.Font;
}
and this is what i get for changing the font size to 14 :
It seems that by using " this.Font " causes the form and the button to resize in proportion with the Font size of the button.
However, by using "btnTest.Font" causes only the font size of the button to change without making the form and button to resize in proportion with the font size of the button.
Can anyone please tell me why is that so ?
|
|
|
|
|
The difference is because the Form has its AutoScaleMode property set to Font (which I believe is the VS default for that property). So when you set the Form font size, it triggers an auto scale, but since the Button does not have an AutoScaleMode property, changing the font size does nothing.
For what it's worth, if you were using WPF, the button would have resized in both situations. So if you really want that resizing behavior and your requirements allow WPF, I would suggest switching. Otherwise, you may end up having to find some component that does it for you or write all the resizing code yourself.
|
|
|
|
|
Thanks alot! I experimented with the AutoScaleMode property and have a better understanding of the reason.
|
|
|
|
|
plz any one tale me how to add rular in toolbar what is the code for..
amitshan
|
|
|
|
|
Click this [^]
Hi this may help You i Suggest Google this u will find many
Happy programming
If You win You need not Explain............
But If You Loose You Should not be there to Explain......
|
|
|
|
|
amitshan wrote: what is the code for..
Wow. Can't do your own code? Google on how to add a ruler to the toolbar, learn how to code it.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi all
I have a problem in counting/extracting matches from a URL string using Regex:
My URL looks like this:
www.website.com/LanguageName/BookName/filename.txt
I use the following code to extract Language name and Bookname:
Match bookMatch = Regex.Match(requestString, "/[^/]*/[^$]", RegexOptions.RightToLeft);<br />
BookInfo bookInfo = new BookInfo();<br />
if (bookMatch.Success)<br />
{ <br />
bookInfo.BookName = bookMatch.Groups[0].Value.Substring(1, bookMatch.Groups[0].Value.Length - 3);<br />
Match langMatch = bookMatch.NextMatch();<br />
if (langMatch.Success)
{<br />
bookInfo.Langauge = langMatch.Groups[0].Value.Substring(1, langMatch.Groups[0].Value.Length - 3); <br />
}<br />
<br />
}<br />
return bookInfo;
Now the code successfully extracts Bookname as it is rightmost in the expression, let us assume that we have the following URL:
www.website.com/LanguageName/BookName/filename.txt
bookMatch will match "/BookName/f", so I remove the 1st one and last two characters to get the bookname correctly.
Now the langMatch doesn't catch the language in the string which should be "/LanguageName/B", it seems that this is happening becoz the 1st match (right to left) has ended at the slash "/" before the BookName, so the search for the next Match will begin on the "e" (last char) character of the LanguageName which will not result in a match.
So how to force the search for the next match to begin on the "/" between the "B" and the "e"?
Any ideas? thanks.
And ever has it been that love knows not its own depth until the hour of separation
Mohammad Gdeisat
|
|
|
|
|
Unfortunately I can't help you with this problem, but why don't you use the Uri class to extract the necessary parts of the URL?
You can use this code:
Uri url = new Uri(@"http://www.website.com/LanguageName/BookName/filename.txt");
string languageName = url.Segments[1];
string bookName = url.Segments[2];
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Excellent, I didn't know about this class
However, if anybody knows how to do it using a Regex then I would be glad to know
Thanks mate
And ever has it been that love knows not its own depth until the hour of separation
Mohammad Gdeisat
|
|
|
|
|
In your case this regex will work, but you have to carefully test it with other URLs:
[^/]/(?<LanguageName>[^/]+)/(?<BookName>[^/]+)/
And some code:
Regex regex = new Regex(@"[^/]/(?<LanguageName>[^/]+)/(?<BookName>[^/]+)/");
Match match = regex.Match(@"www.website.com/LanguageName/BookName/filename.txt");
if (match.Success)
{
string languageName = match.Groups["LanguageName"]);
string bookname = match.Groups["BookName"]);
}
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
What you are looking for is the concept of a lookahead and lookbehind. This pattern should work:
(?<=/)[^/]*(?=/)(?<!$)
I would suggest looking at the documentation to fully understand how lookahead/behind expressions work. Here's a link to get started:MSDN
|
|
|
|
|
Hi, this is silly
How can i force the write in the next line/row?
No Picture Available
No Picture
Available
Thanks
|
|
|
|
|
<br />
Label1.Text = "Line1\nLine2";<br />
|
|
|
|
|
Environment.NewLine
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
this.label1.Text="line 1"+Convert.ToChar(10)+Convert.ToChar(13)+"Line 2";
Regards,
Thomas Stockwell
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.
Visit my homepage Oracle Studios
Discounted or Free Software for Students:
DreamSpark - downloads.channel8.msdn.com
MSDN Academic Alliance - www.msdnaa.com
|
|
|
|
|
It's not clear to me how I am expected to use Queue Synchronization.
Is this a general state, which makes the Queue thread safe? Or is this a short, temporary measure I use to lock the queue before I read or write it, and immediately release it when I'm done?
The documentation and samples are too short and don't go into detail on this.
So my question is: do I simply wrap my Queue with a synchronized wrapper and leave it on, doing all further access through that wrapper?
Or do I only wrap the Queue when I'm accessing it, and immediately drop the wrapper when I'm done?
Do I pass the wrapper to other objects, or only the original Queue?
Thanks for any help here.
|
|
|
|
|
Once you call Synchronized(), you should use the returned wrapper
everywhere you would have used the original unsynchronized queue.
Use of the queue through the wrapper will be thread safe for all
"single operation" methods on the queue.
Make sure Synchronized() is really what you need for a thread safe queue.
Enumerating and indexing the queue aren't going to be thread safe
so you may need additional locks.
Making your own thread safe wrapper (or derived) queue class can
be better in some situations. It allows you to implement locks
the way you need to (like using a ReaderWriterLockSlim for producer/consumer
thread access) and provide properly locked enumerating methods.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for the response. Okay, so the Sync wrapper persistently replaces the Q itself, and it is the object I should pass around between methods, etc. That was not entirely clear to me before.
This should probably work for what I'm doing; I spawn a listener object on a new thread, which listens for events from a COM object. My main thread passes various Queues to the spawned object (actually, sets them as properties), and the spawned object, when it receives messages, puts a notation in the queue(s).
My main thread polls the queue, dequeuing any notations it finds.
So there's no enumerating or indexing, I think. Of course, I haven't written it yet...
|
|
|
|
|
Multiple writer threads and a single reader thread, right?
The Synchronized() queue should indeed be fine for that.
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I have a navigation board(ToolStrip object) above a DataGridView object
I use this code to get data from it.
ToolStripTextBox_Row.Text = DataGridView_Country[0, grid_index].Value.ToString();
Ok, now i want to press Button_NextRow (in navigation board) and
set focus to next row in the DataGridView.
How can i do this?
|
|
|
|
|
It is currently displaying the stack upside down, the contents of the top of the stack are displayed as the last line in the text box. I am trying to make this code display the contents of the stack at the top of the text box.
private void displayStack()
{
string nextItem;
displayBox.Clear();
for (int i = 0; i <= stackTop; i++)
{
nextItem = stackArray[i].ToString();
displayBox.AppendText(nextItem);
displayBox.AppendText("\n");
}
}
|
|
|
|
|
Just loop the other way.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|