|
Your regex is broken (but then so is mine - I'm about to fix it and explain why). You don't want \b before and after. Also, yours would accept 345.567.678.789, which is not a valid IP address!
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
I agree with you, my regex would accept 999.999.999.999 as well. I will update that.
Thanks....
I quit being afraid when my first venture failed and the sky didn't fall down.
|
|
|
|
|
Use a regular expression, such as
^(2[0-4]\d|25[0-5]|[01]?\d\d?)\.(2[0-4]\d|25[0-5]|[01]?\d\d?)\.(2[0-4]\d|25[0-5]|[01]?\d\d?)\.(2[0-4]\d|25[0-5]|[01]?\d\d?)$ (wrap it in whatever delimiters you need.)
If you can't read this, get a copy of Expresso and paste the expression into the expression window.
[edit]I thought it was broken, but it's not... It's just smarter than I am feeling right now. Need coffee! Forget the edit.[/edit]
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Regex is NOT necessary.
Just use IPAddress.Parse(myIPAddress) , and handle the FormatException exception.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
And there we have the correct answer. Regexes are good - when used in appropriate cases. Reinventing the wheel is not the case though.
|
|
|
|
|
Oh John....you wouldn't be using exception handling as program flow control now would you? Naughty boy - go sit in the corner... Perhaps using IPAddress.TryParse() would be less "expensive"?
C# has already designed away most of the tedium of C++.
|
|
|
|
|
The cost in a GUI (per the OP) would be difficult to measure and certainly not significant.
Actually I am not sure what sort of application it would take where this would be expensive. It would require all of the following.
1. IPs arrive as strings.
2. A signficant number are invalid.
3. There are a lot of them.
|
|
|
|
|
I merely mentioned it to avoid being pinged for not doing so. It seems one cannot win.
Besides that, I'm sure intellisense works in his copy of VS, so he may have discovered it on his own.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Depending on the situation, it may be appropriate (i.e. if the vast majority are valid and an invalid one really is exceptional). For UI validation it frankly doesn't matter but from a perspective of style you are correct.
|
|
|
|
|
TextBlock wrapping of text in Silverlight XAML file.
I have a wierd and annoying problem. I have a textblock that is inside a stackpanel that is Oriented horizontal. It would be nice if I could have the textblock appear in multiple lines nicely wrapped. How could I do that?
|
|
|
|
|
Set the textbox textwrapping to wrap
TextWrapping="Wrap"
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello,
I use this code to send files to the FTP server :
FtpWebRequest myRequest = (FtpWebRequest)FtpWebRequest.Create(ftp:
myRequest.Credentials = new NetworkCredential(TEST,HEROS);
myRequest.Method = WebRequestMethods.Ftp.UploadFile;
FileStream stream = File.OpenRead(@"c:\test.txt");
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
stream.Close();
Stream reqStream = myRequest.GetRequestStream();
reqStream.Write(buffer, 0, buffer.Length);
reqStream.Close();
How i can receive the reponse, the server ftp return an ID of commande, i can see this number in FilZilla, bu i need to retrieve this id on C#, thank you verry mutch.
|
|
|
|
|
Use GetResponse[^].
(Also, learn to search, and use the documentation. I found that just from looking at the FtpWebRequest page on MSDN.)
|
|
|
|
|
how i can read cell value when i move up and down with the arrows key in datagridview
using C# code ?
thanks in advance
|
|
|
|
|
as always with Windows programming, split the problem in smaller pieces you can manage:
1.
what events are available that could suit your needs? use MSDN to browse the DataGridView events. Maybe there is something related to the current cell having changed? or the selection having changed?
2.
if such event doesn't offer a specialized EventArgs holding the required information (such as RowIndex and ColumnIndex), then go look for the Control's properties that may help you out.
3.
and finally, try it to see it works in all relevant scenarios.
|
|
|
|
|
Hello,
i am on a little player project in C# i like to give it away for some friends but without this wmp.dll i would just like to give the *.exe and refer to the already existing dll in system32 folder any idea maybe how to can do that?
it works all fine if i import it over the visual studio references (right mouseclick, add..) but than it have to be next to the *.exe file when i wanna start the prog
please give advise
Regards,
Sep
|
|
|
|
|
|
hm bit confusing its not my dll its COM i just saw its located in system32 folder but when i move my exe out of the project folder it wont start with out this dll, i was just trying to DllImport()... but i cant read the classes then so it wont let me compil..
btw how and where can i put it as GAC?
regards
|
|
|
|
|
I don't know the entire answer, however this much I can tell you:
1.
wmp.dll contains native code, hence it can't go into the GAC. Either it holds COM components (which I don't know much about), or it requires P/Invoke to call individual functions (which I have descibed to some length here[^]). And I do expect it to be COM.
2.
If you use P/Invoke (which also means you don't "Add Reference"), the DLL is located in the good old way, in the exe's folder first, then through the system environment variable "PATH", which typically contains C:\Windows\system32\ and many others. The app will start even when the DLL isn't present, however every reference to it will obviously fail during app execution.
3.
OTOH, if you have a hard reference to a DLL (as with "Add Reference"), then the DLL file (and its dependencies) must be present for the app to load successfully.
4.
I'm pretty sure there are several CP articles that refer to wmp.dll, so you could go and have a look how they handle things.
|
|
|
|
|
This[^] SO post may help.
/ravi
|
|
|
|
|
Hi All,
I have a tab which contains multiple controls. I would like to share the tab real estate with two sets of controls. It's easy enough to programmatically hide and view controls however, as the controls share the same real estate it's difficult to manage them visually.
What I would like to do is create two sets of control containers and have the ability to visually work with both containers independent.
When executing the program the user will have an option to swap in and out a set of controls depending on the task type they are working on.
Regards
Patrick
modified on Friday, September 9, 2011 8:01 PM
|
|
|
|
|
Some possible ways:
1) Create user controls for each set of controls. Then you have a few options to display the appropriate set of controls.
a)You can do it at run-time but then you have to manage event hooking.
b) You can put them at there final place and it is somehow less an issue the overlappig since most of the design is done in the user control.
c) Put them elsewhere in your form and move them when the form is loaded. You might put them near the dialog edge so that you can click on each set in the designer.
d)Uses a container like a flow layout container and put each user control in it. At design time, you will see them all. Hide all but one at run-time.
2) Uses third party library that have more complete tab controls that support a wizard mode (as a tab control but without any tab displayed and a way to switch between tab at design time)
Philippe Mori
|
|
|
|
|
Hi, a few queries:
1. "I have a tab" : do you mean you are using a TabControl, and you have one TabPage on which you want to switch between certain sets of Controls, rather than using two TabPages, one for each set of Controls ?
2. or, do you have one TabPage in a TabControl where you want both sets of Controls to show up sometimes, and, at other times, to hide one of them ?
A little more information about the context of what you are working with here would be helpful.
best, Bill
"Is it a fact - or have I dreamt it - that, by means of electricity, the world of matter has become a great nerve, vibrating thousands of miles in a breathless point of time? Rather, the round globe is a vast head, a brain, instinct with intelligence!" - Nathanial Hawthorne, House of the Seven Gables
|
|
|
|
|
Electric Eddy wrote: What I would like to do is create two sets of control containers and have the ability to visually work with both containers independent.
You've received some good suggestions. I often go for a form, group things on there. From there it's quite easy to "paste" the form into a panel, or some other container. Need to show another set of components? Simply clear the controls -collection of the container, and put your new form in there.
void Button42_Click(object sender, EventArgs e)
{
MyForm f = new MyForm();
f.TopLevel = false;
f.BorderStyle = FormBorderStyle.None;
f.Dock = DockStyle.Fill;
f.Visible = true;
panel1.Controls.Add(f);
}
Hope this helps a bit
Bastard Programmer from Hell
|
|
|
|
|
Until the OP clarifies what his issue is, and its context, I think we are "reading tea leaves" here, but I must disagree with you, respectfully, regarding using a Form in the way you show here.
It's a waste of resources, imho, even if you go to the trouble of hiding all the form-adornments, control-box, maximize and minimize buttons, etc.
By the way in the code you show here, if the Form is the last control added to the Panel, the setting of its Dock property to 'Fill means it will fill the Panel and completely obscure any other controls added previously.
The idea that would one would want to "Clear" all the Controls in a Panel, is, to me, also a dubious one: typically you have built-up a set of Controls in a Container for a good reason, and you would want to re-use them, not discard them.
UserControls and Panels, and other "lighter weight" containers, make sense here, given the little we know of the OP's actual scenario.
best, Bill
"Is it a fact - or have I dreamt it - that, by means of electricity, the world of matter has become a great nerve, vibrating thousands of miles in a breathless point of time? Rather, the round globe is a vast head, a brain, instinct with intelligence!" - Nathanial Hawthorne, House of the Seven Gables
|
|
|
|
|