|
|
It depends on what you mean by only numbers. I wrote this one[^], it allows digits only - no negative sign, number separators, currency symbols... just numbers
|
|
|
|
|
Since they're so commonly needed, I have a handy collection of things like signed int, unsigned int, signed float, unsigned float, which do all the validation needed. (Unfortunately it's company code, so I can't give you the source, but they're based on similar ideas to the article linked above.)
It's definitely worth making these once so you'll never be stuck for one again.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Hi All,
How can i change the startup mode for services that are already installed in machine using C# code.
i tried using ServiceController class in C# but i was not able to find any method to change the start up method for services that are already installed.
Thanks in advance
|
|
|
|
|
Vijjuuuuuuuuu........... wrote: How can i change the startup mode for services that are already installed in machine using C# code.
If this is already running, you can change the startup mode from Service Windows [ Run > Services.msc ].
If you want to change it in you code, You have to change the StartUp Type of of your Service Installer.
serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Thanks for reply
but the code that you provided is when we are installing the own service .
My need is i want to change the already installed services , for example windows services are installed with default value . i want to change them .. hope you got my question
|
|
|
|
|
That I have already mentioned to you.
Start > Run > Services.msc> Right Click on The Services > Change the Startup Mode.
If you have to code, then you need to change and reinstall the service again !
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
You could try by changing the Start value in the registry for your service (though I haven't tried this myself, but I figure it would work).
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ServiceName\
Start REG_DWORD (2) <- Change this value to either:
2 = Automatic
3 = Manual
4 = Disabled
|
|
|
|
|
Would it be any problem if we change it from Service Console ?
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
I'm not sure I understand what you mean.. What would be a problem?
|
|
|
|
|
Hi All
I Have a Class name Product.cs that have attributes or properties like id Name Price etc...
Now on run time i have List Of Product Class...
Now i have to Translate this List In to Xml Local Client File... and Serialize and deserialize that..
Pls Help Me
Thanks In Advance..
Sachin
|
|
|
|
|
Serialisation is binary, not XML, AFAIK. I don't know if you can automatically have it done to XML, or if you need to write your own code.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hello Sir,,
I Want to Make a XML File from That Class List locally
|
|
|
|
|
OK, so you need to write a method which takes a stringbuilder, or an XML builder or something, and adds the class instance to the XML document being built. Your solution is to manually write code that creates XML, or reads XML and uses it to create a class instance. Ideally, you want to call a method as you iterate over each class instance, and it builds the XML that way.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
You don't necessarily have to write your own code to manually serialise a class. The XmlSerializer class can handle most of the work.
|
|
|
|
|
here i have an example for you to serialize and deserialize a class
public string SerializeObject ( Object pObject, Type et )
{
try
{
String XmlizedString = null;
MemoryStream memoryStream = new MemoryStream ( );
XmlSerializer xs = new XmlSerializer ( et );
XmlTextWriter xmlTextWriter = new XmlTextWriter ( memoryStream, Encoding.UTF8 );
xmlTextWriter.Formatting = Formatting.Indented;
xmlTextWriter.Indentation = 4;
xs.Serialize ( xmlTextWriter, pObject );
memoryStream = ( MemoryStream ) xmlTextWriter.BaseStream;
XmlizedString = UTF8ByteArrayToString ( memoryStream.ToArray ( ) );
return XmlizedString;
}
catch ( Exception e )
{
System.Console.WriteLine ( e );
throw new Exception(e.Message,e);
}
}
public Object DeserializeObject ( String pXmlizedString, Type e )
{
XmlSerializer xs = new XmlSerializer ( e );
MemoryStream memoryStream = new MemoryStream ( StringToUTF8ByteArray ( pXmlizedString ) );
XmlTextWriter xmlTextWriter = new XmlTextWriter ( memoryStream , Encoding.UTF8 );
return xs.Deserialize ( memoryStream );
}
and here the class how it looks.
[Serializable()]
[XmlRoot("Attrib")]
public class AttributeClass
{
string sIdentifier;
string sAlias;
[XmlElement("Identifier")]
public string Identifier {
get { return sIdentifier; }
set { sIdentifier = value; }
}
[XmlElement("Alias")]
public string Alias {
get { return sAlias; }
set { sAlias = value; }
}
}
and here the AttributeCollection as Class to serialize it..
[Serializable()]
[XmlRoot("AttribsList")]
[XmlInclude(typeof(AttributeClass)),
XmlInclude(typeof(System.Collections.Generic.List<AttributeClass>))]
public class AttribsList : System.Collections.Generic.List<AttributeClass>
{
public static AttribsList LoadLayoutFromFile(string path)
{
try
{
string data_str = Core.SerializeHelper.ReadFromFile(path);
Core.SerializeHelper sh = new Core.SerializeHelper();
AttribsList list = (AttribsList)sh.DeserializeObject(data_str,typeof(AttribsList));
return list;
}
catch
{
return null;
}
}
public static void SaveLayout(AttribsList lst, string path)
{
Core.SerializeHelper sh = new Core.SerializeHelper();
string data_str = sh.SerializeObject(lst,typeof(AttribsList ));
Core.SerializeHelper.SaveToFile(path,data_str);
}
}
}
|
|
|
|
|
Thanks A Lot Brother!!!
Cheers
|
|
|
|
|
HI...
I did DataGridView Search ... As When i type a Text box , the on key up call back Event will filter a Data Grid View Data's ... When i was type the string in fast... Filter for each char So The Searching is very slow and Also Sometimes the Application will hang... How can i Handle this... Or have any other best idea can u share with me
Anish S
|
|
|
|
|
You Can Use Threading to Cope up this problum//// 
|
|
|
|
|
How are you doing the search, what is the underlying datasource, table, bindingsource or collection or List<>.
Depending on the size of your data set and the underlying collection and the method you are using to filter the data it all impacts on the speed. We need some further info to help.
As stated by Sachin you could use a thread to do the filtering but I doubt it will be a satisfactory solution, I think you may have a problem with your design.
|
|
|
|
|
Thanks for reply
I am using List<>... Now i m using List of class object , which have data member , Each member have want to display...
I am searching Code mentioned below...
foreach (SongProfile songPro in songList_)
{
if (searchField_.Equals("File Name"))
{
if (songPro.fileName_.ToLower().Contains(search))
{
tempSongPro = new SongProfile(songPro);
listOfSongPro.Add(tempSongPro);
}
}else if (searchField_.Equals("Song Name"))
{
if (songPro.songName_.ToLower().Contains(search))
{
tempSongPro = new SongProfile(songPro);
listOfSongPro.Add(tempSongPro);
}
}
}
Here after new SongPRofile obj List is Loaded in DataGridView...
|
|
|
|
|
Hi, i have a webbrowser control and i have a button which takes the html from the webbrowser and puts it into a text box. Here is the code:
status.Text = webBrowser1.DocumentText;
However this only seems to work half the time, and when it does not work, i get the error of "File not found".
Or, sometimes it will work once and not a second time.
How can i fix this or how can i do this another easy way?
Must be through the webbrowser control as the client is logged in though it.
Thanks.
|
|
|
|
|
discreetz wrote: However this only seems to work half the time, and when it does not work, i get the error of "File not found".
This sounds strange. Why would you get "File not found" when accessing a piece of text? I would suggest using the debugger to trap your program at the point of error and examine the stack trace and variables to identify exactly which statement is failing and why.
|
|
|
|
|
how to search for a specific file in current directory?
|
|
|
|