|
Use the escape character \
A note from MSDN:
Note If you are using C++, C#, or JScript, special escaped characters, such as \s, must be preceded by an additional backslash (for example, "\\s2000") to signal that the backslash in the escaped character is a literal character. Otherwise, the regular expression engine treats the backslash and the s in \s as two separate operators. You do not have to add the backslash if you are using Visual Basic .NET. If you are using C#, you can use C# literal strings, which are prefixed with @ and disable escaping. For example, @"\s2000"
My latest articles:
XOR tricks for RAID data protection
Win32 process suspend/resume tool
|
|
|
|
|
thanx
1001111111011101111100111100101011110011110100101110010011010010 Sonork | 100.21142 | TheEclypse
|
|
|
|
|
I know that you already found the solution, but you should get Eric Gunnerson's RegEx Workbench app from GotDotNet. It's really useful. And of course, you have the code so you can change anything you don't like...
http://www.gotdotnet.com/userarea/filedetails.aspx?FileName=regexworkbench.zip[^]
Norm Almond: I seen some GUI's in my life but WTF is this mess
Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough
Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children
Leppie:My sister is 25
-Norm on the MailMagic GUI
|
|
|
|
|
And if you find something you don't like, please let me know so I can consider adding it...
|
|
|
|
|
You asked for it...
Just kidding. The only thing I didn't like was when I clicked the button in the top left, the context menu appeared way away from the mouse, in the textbox. So I just changed the parent of the context menu to the button instead. Less mouse travelling that way...
Norm Almond: I seen some GUI's in my life but WTF is this mess
Leppie: I made an app for my sister and she wouldnt use it till it was colorful enough
Norm:good point leppie, from that statement I can only deduce that this GUI must be aimed at children
Leppie:My sister is 25
-Norm on the MailMagic GUI
|
|
|
|
|
Hi,
I have problem with email messages.
I have downloaded email header and I'm trying to get subject of this message.
If there are only english characters, everything is ok
"Subject: emailsubject"
But when I use other characters (I live in Czech Republic ) it looks like this:
"Subject: =?iso-8859-2?Q?Email=20message=20with=20=BE=F8=E8?="
So I want to convert this " " to .Net string (UNICODE)
Thank You
PS: I have seen some code for this on CP http://www.codeproject.com/string/ammimeutils.asp[^], but it doesn't works with other codepages (I think)
|
|
|
|
|
Have you tried looking at System.Text.Encoding.Default ? That will return an Encoding for your default windows codepage.
Dunno if it will work that Good luck
Before you criticize a man, walk a mile in his shoes. That way, when you do criticize him, you'll be a mile away and have his shoes.
|
|
|
|
|
Problem with -> ASP.NET using C#
I am creating a custom user control that reads an xml file and dynamically places labels on the control. This user control will then be placed inside a webform
I am suddenly stuck because I know if I wanted to add dynamically generated controls without a custom user control, which I probably may end up doing if this does not work, I could easily just add this under OnInit function (which is generated by the forms designer.
override protected void OnInit(EventArgs e)
{
// Create dynamic controls here.
// Use "using System.Web.UI.WebControls;"
TextBox1 = new TextBox();
TextBox1.ID = "TextBox1";
TextBox1.Style["Position"] = "Absolute";
TextBox1.Style["Top"] = "25px";
TextBox1.Style["Left"] = "100px";
Form1.Controls.Add(TextBox1);
}
yeah thats from this Q Article.
Thats all fine and good, but you see this line:
Form1.Controls.Add(TextBox1);
What would be the equivalent in a custom User control.
Say my Control is called MyControl.ascx
in my function that reads the xml file and attempts to programatically create a label, every thing is just peachy..but how do I place the label inside my custom control?
I cannot do this:
MyControl somecontrol = new MyControl();
and then in the function do
somecontrol.Contols.Add(myLabel)
wont work!
Cannot create instance of Abstract class or interface? Bah!
I guess I will do it directly from the WebForm, but I just thought there was tremendous coolness value to get it working through a custom control that I could add to a webform without cluttering the webform with all this.
Oh well...if anyone has comments about creating an instance of an abstract class please post!
|
|
|
|
|
You can't create an instance of an abstract class because an abstract class has no implementation, just a list of virtual functions. You can't create an instance of an interface because it's just a list of function definitions (a contract for any inheriting class).
Is MyControl really abstract or have you just put the keyword abstract on it?
Paul
|
|
|
|
|
Paul Riley wrote:
You can't create an instance of an abstract class because an abstract class has no implementation, just a list of virtual functions. You can't create an instance of an interface because it's just a list of function definitions (a contract for any inheriting class).
That explained all I needed to know! MyControl is really abstract, I am @ home now, I will post the code when I get to work..
Thanks!
|
|
|
|
|
public abstract class MyControl : System.Web.UI.UserControl
{
public int countoftext = 0;
public string myType;
public string labelname = "";
public Label mylabel;
public int positiontop = 25;
public int positionleft = 100;
public MyControl tempcontrol = new MyControl();
private void Page_Load(object sender, System.EventArgs e)
{
}
private void ReadMenu()
{
XmlTextReader xmlreader = new XmlTextReader("menu.xml");
while (xmlreader.Read())
{
myType = xmlreader.NodeType.ToString();
if (myType.Equals("Text"))
{
countoftext++;
mylabel = new Label();
mylabel.Text = xmlreader.Value;
mylabel.Style["Position"]="Absolute";
mylabel.Style["Top"] = "" + positiontop +"px";
mylabel.Style["Left"] = "" + positionleft + "px";
tempcontrol.Controls.Add(mylabel);<--WONT WORK
}
}
positiontop = positiontop + 20;
xmlreader.MoveToNextAttribute();
}
I guess I wont use a user control and just do it directly from the form. Oh, and some of the code may seen wrong, I am still learning C#, the code actually does work though, because I was able to display other properties without creating labels on the WebForm1.aspx that was using the custom user control, like showing the Encoding of elements in my xml file, or the count, etc blah ..
|
|
|
|
|
This doesn't look very abstract to me. What happens if you take the word out completely?
By the way, I wouldn't advise creating an instance of a class in the definition for that class. The new instance will also create a new instance, the new new instance will then create another one, and so on.
Dangerous ground, I'm surprised it compiles. (unless I'm missing something fundamental)
Paul
Life is just a sexually transmitted desease - Matthew Wright (ex-journalist, TV presenter) 10-Oct-02
I finally have a sig! - Paul Riley (part-time deity) 10-Oct-02
|
|
|
|
|
I am trying to detect when the user clicks on the actual tab of a tabcontrol object in order to display a context menu.
I don't want to put the context menu in the associated property of the tabcontrol because it will automatically pop up when the user clicks anywhere on the tabcontrol.
I just want to detect when the user clicks on the actual tab.
Can someone help me out?
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|
|
Hi All,
If there is an unmanaged code in a application then how does the compiler handle that unmanaged code.Is the unmanaged code directly compiled into native code without first converting into MSIL or is there some mechanism with the compiler to handle such unmanaged code and thus convert it into MSIL.I would like to know how this processing of the unmanaged code is done by the compiler.
Thanks
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
I'm presuming that you're talking about C++ code, since there is not unmanaged C# code.
For C++ code, the code that is compiled with /clr is compiled to IL. Code without that is compiled to native. C++ supports having both managed and unmanaged code in the same exe.
|
|
|
|
|
Can somebody tell me exactly what order events are fired when a form displays. I want to do some processing immediately *after* the form has been displayed, and not before which happens if I put the code in the constructor. Which event handler is best to override to do this? I tried VisibleChanged, but that fires when ever the visiblity changes (including when the form closes) and not just the first time.
Thanks
|
|
|
|
|
|
You could use the Form Load or Activated events. In the case of Activated, you may need to set a boolean variable to prevent taking care of your action twice.
Gaul
|
|
|
|
|
Actually the Load event fires before the form is loaded, but the activated event works just fine.
|
|
|
|
|
Hi,Everyone!!
make string = "31323334" ('31','32' ... is HEX) to string = "1234"???
who can help me?
|
|
|
|
|
Are you dealing with just numbers, or letters too: 656667="ABC"? If you're dealing with just numbers, you could employ a cute trick and get rid of the first, third, fifth, etc. '3' character (I can't remember if 30=ASCII '0' though).
Marc
|
|
|
|
|
Hi all,
using System.Runtime.InteropServices;
...
[DllImport("ole32.dll")]
public static extern long CLSIDFromProgID(string ProgID, out Guid clsID);
...
Guid clsID;
long ret = CLSIDFromProgID("Excel.Application", out clsID);
if(ret==0)
System.Console.WriteLine("OK.");
else
System.Console.WriteLine("Fail.");
I use above codes for checking Microsoft Excel is installed or not. But it doesn't work at all, even if I already installed Microsoft Excel.
Are there any missing in my codes?
|
|
|
|
|
[DllImport("ole32.dll", CharSet=CharSet.Auto)]
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
Hi Stephane,
Thanks for your help.
I changed my codes as you suggest but it still doesn't work. I think I don't set type of parameters accurately.
Do you think my declaration below is correct?
[DllImport("ole32.dll", CharSet=CharSet.Auto)]
public static extern long CLSIDFromProgID(string ProgID, out Guid clsID);
Many thanks.
|
|
|
|
|
The return type is a 32-bit integer, which is int , not long .
Have you tried:
Type Excel = Type.GetTypeFromProgID("Excel.Application");
if (Excel == null)
Console.WriteLine("Fail.");
else
Console.WriteLine("OK.");
|
|
|
|