|
First, why are you doing this?
Mehmet Fatih Akbulut wrote: if (Convert.ToInt32(sp.BytesToRead.ToString()) > 0)
All you're doing there is: converting an integer to a string, then parsing that string back into an integer. That is useless, there is no need to convert to a string. Just use
if(sp.BytesToRead > 0)
{
...
}
Second, what error are you getting? Did you call sp.Open() before trying to read the data?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Islamic Domination: Coming to a Jewish state near you!
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Dear Experts
I have an Act.X in my source code,showing a map and without any routine for print it context.I guess I can print its context using Draw method and passing a printer device context to it.But I can't find any way to take a printer device context else using win32 API.Is there any way in .NET framework (C#)and managed code to do it?
Any help will be highly appreciated
Regards
Reza
|
|
|
|
|
How to identify the enter key is pressed inside a textbox
Deepak
|
|
|
|
|
hi Deepak Dhongde! =)
if your inherting a textbox override the OnKeyDown method & if not attach a handler on the KeyDown event of your textbox, then add this condition:
if (e.KeyData == Keys.Enter)
{
}
hope this helps!
microsoc
|
|
|
|
|
In the KeyUp event of this text box you can check the KeyCode property of KeyEventArgs object,using this enumeration System.Windows.Forms.Keys.Enter.
here is a sample code
private void textBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode==System.Windows.Forms.Keys.Enter)
MessageBox.Show("successful");
}
|
|
|
|
|
The RichText and the TextBox controls have the property Lines that of type string[]. Any idea how the controls handle the resizing of the Array?
I want to know because I want to use an Array, which will hold properties for each Line of the TextBox control.
Or do you have any suggestion what should I do best?
|
|
|
|
|
I seriously doubt these controls store the array - the property most likely convert to and from the "native" format when you call the get or set method.
So the solution is to use a collection:
List<string>
|
|
|
|
|
You could store each of your lines in an ArrayList, which autosizes for you when you Add or Remove . As long as you only put strings in there, you can use 1 simple line when you want to assign the lines:
string [] lines = (string[])myArrayList.ToArray(typeof(string));
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
the TextBox controls create a new string[] everytime you request the Lines property. It is not stored; it's generated on-the-fly.
As a side note (not that it will help you here) but one can resize an array using the Array.Resize static method.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Islamic Domination: Coming to a Jewish state near you!
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
Hello,
Which is the best source code wizard ?
Which is the easiest to understand source code wizard ?
Thanks
|
|
|
|
|
What are you asking for ? The wizards are all good at creating shells for different types of program. Each wizard is the best for the task it was written for.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi!
When calling a namespace like using MyNameSpace.Members, lets say there is 50 classes in this namespace, are all 50 called? Wouldn't this cause a performance dip? I know in Java you can specify which classes you want to include.
How does one say, do I include the namespace, reference it or what?
Regards,
ma se
|
|
|
|
|
The classes are not called at all, they are simply included in the namespace lookup done by the compiler.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
ma se wrote: lets say there is 50 classes in this namespace, are all 50 called? Wouldn't this cause a performance dip? I know in Java you can specify which classes you want to include.
It might cause a slight dip in the compiler as it resolves the classes to the correct assembly, but it wouldn't affect the runtime.
"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
|
|
|
|
|
Hi!
Is there a written rule as to when constructors with parameters are to be used? I usually do it like this?
MyClass objMyClass = new MyClass();<br />
objMyClass.Name = "MyName";<br />
objMyClass.Age = 26;
The following could also be used:
MyClass objMyClass = new MyClass("MyName", 26);
The reason why I asked because I once had a class that required about 30 values, and passing it in the constructor looked messy.
Regards,
ma se
|
|
|
|
|
If the value is required (so the object makes no sense without it) it should be in the constructor.
Besides this, use whatever makes the code most intuitive.
|
|
|
|
|
Generally, the object should be fully functional once it's created. For practical reasons you might have to make exceptions from the rule, though.
If possible you should still try to verify that the required values are set before they are used.
---
b { font-weight: normal; }
|
|
|
|
|
again am asking if any one could help i have a problem in begining the code of Ezstego algorithm for steganography detectiong of color palette images.how could i extract the hidden message if the message bits are hidden in the LSB of every color byte of the cover image? using c# language
|
|
|
|
|
You only posted your first question 15 hours ago! Give people a chance to respond. Also, consider that it is possible that people here don't know the answer to your question.
Have you used an internet search engine to try and find an answer?
"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
|
|
|
|
|
Hi!
How do I "disable" a theme for a specific page? I have set my theme in the web config page, but there is one page that I want to use a different stylesheet.
Regards,
ma se
|
|
|
|
|
Hi,
Can i know how to pass the address of the variable in c#?
Following is the code in c which has to be converted into c#..
public int Largest(int *ptr,int Icount)
{
int largest =0;
largest = *(ptr+0);
for(int i=0; i < Icount; i++)
{
if( *(ptr+i) >= largest)
{
largest = *(ptr + i);
}
}
return largest;
}
plz let me know how to sent the reference and increament the pointer.
|
|
|
|
|
you can use ref key word in c# to send the reference of variable
public int Largest(ref int ptr,int Icount)
{
int largest =0;
largest = (ptr+0);
for(int i=0; i < Icount; i++)
{
if( (ptr+i) >= largest)
{
largest = (ptr + i);
}
}
return largest;
}
rahul
-- modified at 5:08 Monday 15th May, 2006
|
|
|
|
|
Thanks Rahul...
But i'm getting error "Identifier Expected" so any idea....
|
|
|
|
|
sorry i forgot to add int after ref key word add it and try
rahul
|
|
|
|
|
From within a property grid, I want to use the a CollectionEditor that is able to display a selection dialog once the "Add" button is clicked. That is, I want the user to choose collection items from a defined list and add them to the collection in CollectionEditor.
For example, in VS 2005 property grid of a windows form, if you want to add an image to a System.Windows.Forms.ImageList, the appropiate property grid displays an image chooser dialog once "add" is clicked. I want to implement something similar to this feature. Any ideas or hints? thanks.
|
|
|
|