|
If you're using .NET 2.0 use a TryParse method, such as Int32.TryParse, to see if a string contains a number. If you're using .NET 1.x, then call Int32.Parse or Convert.ToInt32 - but be sure to wrap that call in a try/catch block because if the conversion fails, an exception will be thrown.
Checking if a string contains multiple numbers, like "12 43 656 234523 24", you can use the Split method of the String class to break the input into an array of strings. Then call Parse or TryParse on each string in the array. Beware that calling Split has subtle issues if the input value has multiple spaces in a row. You might want to remove extra spaces, or some other precautionary measure, before parsing the text into numbers.
josh
|
|
|
|
|
will that work if my string is sth like "abc12def"? the check function should return true if it found a number inside a string.
Donkaiser
|
|
|
|
|
No. You can use a regular expression, or loop over each character in the string and use Char.IsNumeric() to check if each char is a number.
Josh
|
|
|
|
|
hi
i could add exe file to my vstudio solution and set build action to Embedded Resource and by working with resources i could take it to stream .
i want to run my exe .. how to that ??
My code is ::
string fullName = this.GetResourceFullName("HDCopy.exe");//i want to run this exe
Stream stream = this.asm.GetManifestResourceStream(fullName);//load my exe to memory
//How to Run My exe from Memory (Stream) ??
private string GetResourceFullName(string resName)
{
string fullName = null;
foreach (string str in this.asm.GetManifestResourceNames())
{
if (str.EndsWith(resName))
{
fullName = str;
break;
}
}
return fullName;
}
HDCopy.exe is not dot net .
|
|
|
|
|
Check out the post by Steve Hanson at the bottom of this article[^]. It shows how to extract and run a managed EXE from an assembly. I'm not sure if it will work with unmanaged EXEs, though.
josh
|
|
|
|
|
how can i search in combo box by latter ,and the first match word be the text of the combo
MD_NADA
|
|
|
|
|
Beg, borrow and steal.
See CompletionCombo in the free Genghis controls:
http://www.sellsbrothers.com/tools/Genghis/[^]
If you don't like how it handles it, you can change the code. There is a lot of learning packed into the source code available there.
|
|
|
|
|
I think you might mean "How do I get a combobox to autocomplete input based on a letter?", if so, check out the combobox.autocomplete methods. look at AutoCompleteSource, AutoCompleteMode autocompletestringcollection.
I did this on the fly, so don't copy it word for word, but this should give you an idea.
//this assumes 2 comboboxes, cbSource and cbDestination.
<br />
private void BuildCompleteList()<br />
{<br />
AutoCompleteStringCollection cityList = new AutoCompleteStringCollection();<br />
foreach(DataRow dr in myCityInformationTable)<br />
{<br />
cityList.Add(dr["CityName"]);<br />
}<br />
cbSource.AutoCompleteCustomSource = cityList;<br />
cbList.AutoCompleteCustomSource = cityList;<br />
}<br />
In addition, remember to set the cb autocompletesource property for each combobox to custom source, and autocomplete mode to either SuggestAppend, Suggest, or Append as suits your functionality needs.
Hope this helps.
//Also, code from this was paraphrased from an example on page 160 of Brian Noyes "Data Binding with Windows Forms 2.0". I figured that I wrote this example, but I used his example as a starting point. Its a great reference for all your databinding/etc needs.
|
|
|
|
|
excuse me this is not i want
i want to search in the combobox like MicroSost forms20 combobox in com componants
please clear the answer becuase i am a bigner
thanks for helping me
MD_NADA
|
|
|
|
|
Hi,
I am trying to get the User details from an active directory but the code gives me only User names. I want their entire details like....eg. - User1 Domain/Test/Test1....
Urgent help is required.
Thanks.
Pooja.
Nothing is Impossible.
-- modified at 7:22 Friday 9th June, 2006
|
|
|
|
|
The System.DirectoryServices.SearchResult class gives you all details.
After your Active Directory search, list all available properties and find the details you need:
foreach(string name in searchResult.Properties.PropertyNames)
{
Console.WriteLine("{0} = {1}", name, searchResult.Properties[name][0].ToString());
}
_________________________________
Please inform me about my English mistakes, as I'm still trying to learn your language!
-- modified at 7:44 Friday 9th June, 2006
|
|
|
|
|
Hi,
Thanks. Your reply helped me a lot. One more thing I would like to ask here. I have a textbox in which let say I enter pooja.katiyar...this is my sAMAccountName. but when I click on the search button how can I get the property name for that particular value?
Actually I am trying to build a filter. In my UI I have a textbox and button. Whatever I enter in the textbox and click on the button, it should be able to find that record if it exists!
Thanks.
Pooja.
|
|
|
|
|
Hello All!!
I have created a windows service and the problem is when I log off my system account in which the service is currently running, the service stops. Why is this so? I want my service to run independent of my system account.
Thanx in advance
regards
Mubashir
Storan Technologies (USA)
|
|
|
|
|
Is it a real windows service?
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
-- modified at 10:42 Friday 9th June, 2006
|
|
|
|
|
How can i edit a ListViewSubItem in ListView control in C#.
I have set the View property of ListView Control to View.Details.
I set the LabelEdit property to true but it only lets editing 0th index listviewsubitem.
Thanks
|
|
|
|
|
System.Windows.Forms.ListView does not support that.
Try the article search for "editable list view".
_________________________________
Please inform me about my English mistakes, as I'm still trying to learn your language!
|
|
|
|
|
Is SqlCommand object can contain more then one outputparameters.
if say yes, how can i get the output value.
|
|
|
|
|
maaran wrote: Is SqlCommand object can contain more then one outputparameters.
Yes, it can contain more than one output parameter
maaran wrote: how can i get the output value
By asking each SqlParameter for its Value after the SqlCommand has been executed.
"On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question."
--Charles Babbage (1791-1871)
My: Website | Blog
|
|
|
|
|
can you give one simple sample with two output parameter
|
|
|
|
|
Not complete, but it should give you enough to work with:
SqlParameter p1, p2;
p1 = new SqlParameter( ... );
p1.Direction = ParameterDirection.Output;
p2 = new SqlParameter( ... );
p2.Direction = ParameterDirection.Output;
theCommand.Parameters.Add(p1);
theCommand.Parameters.Add(p2);
theCommand.Execute( ... );
firstValue = p1.Value;
secondValue = p2.Value;
---
b { font-weight: normal; }
|
|
|
|
|
I wrote a class named Region, which encapsulates the content of a part of the screen.
Region keeps two Bitmap objects: content, and lastContent,
and it compares them via this code:
private void checkForChange()
{
for (int y = 0; y < bounds.Height; y += 10)
for (int x = 0; x < bounds.Width; x += 10)
if (content.GetPixel(x, y) != lastContent.GetPixel(x, y))
{
userCallBack(this);
return;
}
} In the main program, I have an array of Region object, each representing a different part of the screen.
I use a new thread for each region check, and when a check is finished, I reactivate it.
However, this consumes a great deal of CPU.
Task Manager shows between 15 to 25 CPU usage.
Any ideas regarding how to decrease the CPU usage (not at the algorithm level)?
Thanks,
Shy.
|
|
|
|
|
You could set the priority (something like ThreadPriority on the Thread class) of the thread lower.
Other then this using GetPixel is rather slow. Have a look at this[^] article series on how to do it faster.
|
|
|
|
|
Thanks! Looks good!
I'll get right on to it, and come back here with my future questions
Thanks again!
|
|
|
|
|
Well...
I tried using pointers like the article described...
Didn't help much...
This is my new code:
private void checkForChange()
{
Rectangle r = new Rectangle(0, 0, bounds.Width, bounds.Height);
BitmapData dataContent = content.LockBits(r, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
BitmapData dataLast = lastContent.LockBits(r, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
int stride = dataContent.Stride;
int offset = stride - dataContent.Width * 3;
int width = dataContent.Width * 3;
int height = dataContent.Height;
unsafe
{
byte* pContent = (byte*)dataContent.Scan0;
byte* pLast = (byte*)dataLast.Scan0;
for (int y = 0; y < height; ++y, pContent += offset, pLast += offset)
for (int x = 0; x < width; x += 3, pContent += 3, pLast += 3)
if (pContent[0] != pLast[0] || pContent[1] != pLast[1] || pContent[2] != pLast[2])
goto Found;
}
Cleanup:
content.UnlockBits(dataContent);
lastContent.UnlockBits(dataLast);
return;
Found:
userCallBack(this);
goto Cleanup;
} It even uses more CPU...
Ideas?
|
|
|
|
|
Hello all,
in my Win Applicaiton. i am using TabControl. In this I added 2 Tabs. I want to disable second tab. It is not having Enabled Property.
How to do this
any sounds will be appriciated
regards
GV Ramana
|
|
|
|