|
UInt32 or Int32 are equivalent to DWORD in c#.
|
|
|
|
|
Seems it is fine. Thanks a lot.
At the same time I found one thing. bool type variable gives the same output as DWORD. Do you guys know about it?
I appreciate your help all the time...
Eranga
|
|
|
|
|
I have a panel control contain 3 label on these labels i am using barcode font Code 39 now i want to print these barcode but i am unable to do so..
Can any one give me a code to print these barcodes.
|
|
|
|
|
Use DrawToBitmap method of control to draw image of control on a bitmap object.
After this you may use a PrintDocument and PrintPreviewControl and you may draw this bitmap image on PrintDocument using PrintPage event.
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Hi,
Does anyone have code that will communicate to the USB port to send and receive data in C#.
Thanks in advance,
Praji
|
|
|
|
|
|
|
Hi all,
In the form load of a text box, I want to display a value from the registry. So I try this in InitializeComponent() as follows.
namespace ServerStarter
{
public class Form1 : System.Windows.Forms.Form
{
private RegistryKey regKey =
Registry.LocalMachine.OpenSubKey( "SOFTWARE\\Test\\MyTest", true );
private void InitializeComponent()
{
this.textBox1.Text = regKey.GetValue("server");
}
}
}
Here server is one of the value in my regKey registry sub key. This code gives an error
F:\Projects\FocusGroupServer\ServerStarter\Form1.cs(467): Cannot
implicitly convert type 'object' to 'string'
can you tell me where I'm going wrong.
Thanks.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Ok, I found where I'm going wrong with my code. I have to use them as a string.
So,
this.textBox1.Text = regKey.GetValue("server").ToString();
This works for me fine, in form load the correct value is displayed on the text box. But gives a warning says
The variable 'regKey' is either undeclared or was never assigned.
And also I found one funny thing. Suddenly after doing some design modification, the textBox1 text set to empty as
this.textBox1.Text = "";
This is happened automatically. Why is that. In compile time I don't get any error at all. I'm really worried about it....
I appreciate your help all the time...
Eranga
|
|
|
|
|
hello friend,
u may combine your code and donot need to store value on a variable like regkey. Like this :
TextBox1.Text = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Test\\MyTest", true).GetValue("server").ToString();
OK.
Reply.
Best of Luck.
Dipak
|
|
|
|
|
Initially I though about it, but not tested. Because say I put more texboxes later, say all together there is 5 boxes. So I have open a same registry key 5 time. Is that ok.
After the line
dipak.dipak wrote: TextBox1.Text = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Test\\MyTest", true).GetValue("server").ToString();
I can't do,
Registry.LocalMachine.OpenSubKey("SOFTWARE\\Test\\MyTest", true).Close();
because such logics are not allowed in InitializeComponent(), isn't it?
I appreciate your help all the time...
Eranga
|
|
|
|
|
Yeah, u r right. If u didnot initialize that component than why r u going to close?
As u said : "put more texboxes later, say all together there is 5 boxes. So I have open a same registry key 5 time."
than u may retrive the registry value once and store in a String variable and set text of other textboxes.
String strRegVal = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Test\\MyTest", true).GetValue("server").ToString();
TextBox1.Text = strRegVal;
TextBox2.Text = strRegVal;
TextBox3.Text = strRegVal;
TextBox4.Text = strRegVal;
TextBox5.Text = strRegVal;
Is it OK as u want?
Best of Luck.
Dipak
|
|
|
|
|
Yes it's true. But I'm still wired on it pal. Say I want to display five different registry values, that mean I have five different names. So I have to use five sub keys in your way. Isn't it?
By the way I tried one way. As usual write a separate function to set the initial values on to text boxes and call that function in form load. What you think of it. There is no any warnings either.
I appreciate your help all the time...
Eranga
|
|
|
|
|
CodingLover wrote: the textBox1 text set to empty... This is happened automatically
You really shouldn't do this in the InitializeComponent method as it's likely to get erased. It's safe to hardcode a value in there i.e. this.textBox1.Text = "Initial Text"; .
When you modify your form in the designer, let's say you add a text box, the VS rewrites the InitializeComponent adding your new text box to it and setting some basic property values. It does the same anytime you modify a property in the designer. When it does this, the whole method is rewritten and any changes you made will most likely get erased in the process.
Before the InitializeComponent method there is this to warn you:
#region Windows Form Designer generated code
You should put your code either in the constructor after the call to InitializeComponent, or better still, in a seperate method to be called afterwards.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
OtherInitializations();
}
private void OtherInitializations()
{
this.textBox1.Text = regKey.GetValue("server").ToString();
}
}
Dave
|
|
|
|
|
Yes,
That's what I have done on my last post. As far as I feel, I can edit only the initial properties of controls, without using the Properties window.
Only I can't put any logic there. Isn't it.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Yes, that's correct. Any properties that can be set in the properties window AND the values that can be entered there will be OK. Anything else you should do in your own method or in the constructor AFTER InitializeComponent
Dave
|
|
|
|
|
I was looking for an application that will monitor how much traffic I send and receive via the internet only.
Most of the programs I looked at had far more features than I need (though NetLimiter was very nice). I thought this might be a good opportunity to try writing my own.
However I am not really sure where to start.
What classes would let me look at the internet traffic and record the size of each inbound/outbound packet?
I have heard mention of something called winPcap, but not really sure how to use it.
Any pointers appreciated...
|
|
|
|
|
|
Hello,
I´m a novice portuguese programmer and I trying do build one application that traces/shows the computers that pinged me, for good or bad reasons i dont care!. I want to put it in a log application.
I just want do know how pinged me, know his/her ip, location,start and end of comunication, etc,etc.
And i having dificulty on finding documentation on doing that.
Can anyone can help me on this task?
Thank you
|
|
|
|
|
|
Here is the format:
$75 3/2/2008
How do I find just the second and third character? The 75 ?
|
|
|
|
|
Well, the simplest, and least flexible way is to get the second and third characters out of the string, perhaps like this:
string sNumber = listboxitem.SubString(1,2);
int iNumber;
Int32.TryParse(sNumber, ref iNumber);
I might have got the params for TryParse wrong, but thats the easiest way to do it.
Of course if the number went to 3 digits it wouldn't get the whole number.
My current favourite word is: Nipple!
-SK Genius
|
|
|
|
|
for (int z = 0; z < PaidToDateListbox.Items.Count; z++)
{
int count = 0;
string thenumber = PaidToDateListbox.Items[z].ToString();
int length = thenumber.Length - 3;
thenumber.Remove(3, length);
thenumber.Remove(0, 1);
count = count + Convert.ToInt32(thenumber);
}
This is what I had and I get this error:
Input string was not in correct format.
|
|
|
|
|
Hi,
1.
string.Remove() does not modify the string, it returns a new string, so you should
write thenumber=thenumber.Remove(3, length); etc.
That is because strings are immutable, nothing in .NET can modify them.
2.
If you are only interested in part of a string, string.Substring() is the method you want,
hence thenumber=thenumber.Substring(1, 2); holds the second and third char.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Are you trying to just show the 2nd and 3rd characters in the list box, or get the 2nd and 3rd chars of the selected text in the list box?
If the latter, try the following:
<br />
string selectedText = listBox1.SelectedItem.ToString();<br />
textBox1.Text = selectedText.Substring(1,2);<br />
<br />
<br />
char[] selectedTextChars = listBox1.SelectedItem.ToString().ToCharArray();<br />
textBox1.Text = selectedTextChars[1].ToString() + selectedTextChars[2].ToString();<br />
There could well be a better ways though. This way will give you problems if the format changes, or it goes to three digits.
Hope that helps...
|
|
|
|