|
Call ToString("X") on your int/byte variable to return a string representation of its value in hexadecimal format.
Paul Marfleet
|
|
|
|
|
To be a bit more precise, do this kind of conversion in a TypeConverter (a converter derived from Int32Converter for example) ConvertFrom/ConvertTo methods and attach this converter to your property thanks to the TypeConverterAttribute.
|
|
|
|
|
Thanks for the help. I was hoping that I could set a property on the PropertyGrid to show all of the objects integer types as hex (like in the watch display in the debugger), but I'll proceed with the TypeConverter.
Regards.
"We may not be the smartest in the world, but we're the smartest you've got."
-a co-worker, speaking to our manager
|
|
|
|
|
|
Here we go...that should have been for the lounge, so I deleted it - just as you answered....so....nobody knows what you are apologising for....but I forgive you...
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
See... now I seem mysterious
|
|
|
|
|
I need to get a list of domain names hosted on an ip address ..
is that possible ..
some one told me that it can be done using TelNet
Thanks in advance, I really appreciate your help in any way.
|
|
|
|
|
Definately not with telnet. I don't think you can do this. What you need to look at is the virtual servers configured on the IP's webserver. That information is not accessable to any other then the administrator of that machine so I don't think what you are asking is doable.
|
|
|
|
|
Not really 100% sure what you are looking for but try the following from the command line.
nslookup ipaddress
Mike Lasseter
|
|
|
|
|
Hello!
I'm pretty new to C# and this is a newbie question, so I'm sure I can get help
I get the following message when I try to run the program in Visual C#: "The name 'rightAnswer' does not exist in the current context".
Anyway, here's the code:
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
<br />
namespace Multiplikation<br />
{<br />
public partial class Form1 : Form<br />
{<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
public void getQ()<br />
{<br />
Random r = new Random();<br />
int maxRand = 9;<br />
int firstNumber = r.Next(maxRand);<br />
int secondNumber = r.Next(maxRand);<br />
label3.Text = firstNumber + " * " + secondNumber;<br />
int rightAnswer = firstNumber * secondNumber;<br />
}<br />
<br />
public void button1_Click(object sender, System.EventArgs e)<br />
{<br />
int theRight = rightAnswer;<br />
<br />
int answer = int.Parse(textBox1.Text);<br />
<br />
if (answer == theRight)<br />
{<br />
label4.Text = "Right answer!";<br />
}<br />
<br />
else<br />
{<br />
label4.Text = "Wrong Answer!";<br />
}<br />
<br />
getQ();<br />
}<br />
<br />
}<br />
}<br />
|
|
|
|
|
The variable 'rightAnswer' is only local to the method getQ()
And you can't access it from anywhere else.
Add a class variable or something, so you'd end up with:
public partial class Form1 : Form
{
private int rightAnswer;
...
public void getQ()
{
Random r = new Random();
int maxRand = 9;
int firstNumber = r.Next(maxRand);
int secondNumber = r.Next(maxRand);
label3.Text = firstNumber + " * " + secondNumber;
rightAnswer = firstNumber * secondNumber;
}
public void button1_Click(object sender, System.EventArgs e)
{
int answer = int.Parse(textBox1.Text);
if (answer == rightAnswer)
{
label4.Text = "Right answer!";
}
...
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
First, please use the <pre> tags to format large code blocks like this.
From the nature of this question, it would appear that you're pretty new to programming and not just C#. Do you understand what the compiler error is saying in "plain english"? "Scope" essentially refers to anything inside a { } pair, so the class forms one scope and each method inside that class forms another scope (each method is it's own scope). Scope is limited as you go further into the class, so things inside a method are not visible to things outside of the method.
As long as you understand that concept, if you take another look at your code you should see the following things (as they relate to your error message):- The variable
rightAnswer is defined inside a function named getQ .
- The function
button1_Click tries to use the variable rightAnswer
Given the rules of scope I mentioned, the variable is only defined within the getQ method and is not visible outside of that method.
In order to do what you want, the variable must be defined outside of any methods, but inside the class, which gives it a "class-wide" scope. Since it is defined at a higher scope, it is visible to any methods defined. Generally, class variables like this are defined at the top of the class (just under the public partial class Form1 : Form line but before the constructor.
|
|
|
|
|
Hi,
What Installation System do you recommend the most? Do you know of any side-by-side comparisons of the big ones out there (I searched for a while with no luck)? Currently my company uses InstallShield but we're looking into moving into an OpenSource installer (probably Inno or NSIS) and I was wondering if there were any clear cut advantages to one installer vs the other (No one here has any experience with either one). Thanks.
|
|
|
|
|
Hi!!
My experience about installers include WindowsInstaller and Inno Setup. Inno Setup is free and is easy to use. When I can't embbed components in WI because are'nt compatible I replace with IS.
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|
|
This is a really easy question i hope.......
for example you have the following code;
private void Form1_Load(object sender, System.EventArgs e)
i would like to know what the bold part means??
im not too concerened about Form1_Load event, its just the parameters of any event. I cant seem to understand
I have tried looking in books but had no success.
Please help
Cheers
|
|
|
|
|
hustler2005 wrote: I have tried looking in books but had no success.
Don't understand why. There is plenty of documentation, and you couldn't find anything?
sender is rather obvious, the sender of the event. EventArgs is the data generated from the event
only two letters away from being an asset
|
|
|
|
|
sorry, what i meant is "i have had no success" in understanding what i have read. if someone could explain it a lil more clear/easier to understand??
it would make my day!
Cheers
|
|
|
|
|
As Mark said, there is already a lot of information about this online.
Anyway, the sender parameter is an object representation of the control that caused the event to be sent. It is an object , which means that you need to have some knowledge of what the actual sender is supposed to be if you want to use it inside the event handler. In order to use the sender you need to cast it to the appropriate type. In the case of your example, you would need to do one of the following:
private void Form1_Load(object sender, System.EventArgs e)
{
Form f = sender as Form;
if (f != null)
{
}
} or
private void Form1_Load(object sender, System.EventArgs e)
{
Form f = (Form)sender;
} To me, the preferred way is the first one since it is a bit safer.
The e parameter represents the "EventArgs" of the event. In reality, EventArgs is a class that is used to hold the data generated by the event that could be used within the event handler. All events should use either the System.EventArgs class or a custom (derived) System.EventArgs class. The default System.EventArgs class maintains no data about the event.
|
|
|
|
|
Thanks Scott/Matt for your input.
You mention there is alot of documentation online, can you suggest a good starting point??
This would be very help indeed.
Cheers
|
|
|
|
|
|
Hi all,
I'm using the CellsPainting event to draw a bitmap for a particular header cell. Here is code that does this(the bitmap is in an imagelist).
//this.images is an ImageList with my bitmap
void dataGridView1_CellPainting(object sender,
DataGridViewCellPaintingEventArgs e)
{
if (e.ColumnIndex == 1 && e.RowIndex == -1)
{
e.PaintBackground(e.ClipBounds, false);
Point pt = e.CellBounds.Location;// where you want the bitmap
in the cell
int offset = (e.CellBounds.Width -
this.images.ImageSize.Width) / 2;
pt.X += offset;
pt.Y += 1;
this.images.Draw(e.Graphics, pt, 0);
e.Handled = true;
}
}
I;m using the MOuseDown event to get the index of the right clicked column
private void dataGridView1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
DataGridView.HitTestInfo hit = dataGridView1.HitTest(e.X, e.Y);
poz = dataGridView1.Columns[hit.ColumnIndex].Index;
dataGridView1.CellPainting +=new DataGridViewCellPaintingEventHandler(dataGridView1_CellPainting);
}
}
My problem is that when reordering the columns the headerCell is going crazy. The header cell value, witch is a string(the column name) starts to have a strange behavior.
Is there anything I'm missing here please?
|
|
|
|
|
Hello, I need your help and guidance, I am feeling lost.
I have a tcp/ip socket server application that receives messages threw a router.
my hardware sits on wireless network, creating messages, and pushes them to a tunneling router than in it's time push the messages to a middleware PC
with a socket server program, listening for the data.
my problem is, when i disconnect the tunneling router and reconnect, the connection breaks, and I can't keep receiving messages from the router.
this causes an instability issue for me, since network crashes can happen, and I need my network to survive them.
what you think might be the problem?
How can I solve it?
any help will be most appreciated.
|
|
|
|
|
gizmokaka wrote: the connection breaks
What connection? I am not able to clearly understand your layout description.
|
|
|
|
|
OK from the top:
I have a wireless RF network in which I have units running and sending messages.
the receiving end for the messages is a tunneling router with one end RF receiver and the other has
TCP/IP port, and this tunneling router translates from one network to TCP/IP packets then it forwards
the messages to a PC that's running socket server application that listens constantly on a specific port, and when data is received it handles it.
when I say the connection breaks I mean, I disconnect the tunneling router from the network,
and reconnect it.
when it's reconnected it's no longer able to receive messages.
the thing is, if I disconnect the network cable it simply breaks with a message box
saying something about lost messages and stops receiving messages, but the program doesn't crash.
but if I disconnect it's power, it breaks with an exception
"An existing connection was forcibly closed by the remote host"
and stops the program.
of course I am talking of debug mode.
hope it's clearer now.
if my reply will be late, I am sorry, I promise to reply to every comment
tonight or tomorrow.
thanks again for your help.
|
|
|
|
|
gizmokaka wrote: OK from the top:
I have a wireless RF network in which I have units running and sending messages.
the receiving end for the messages is a tunneling router with one end RF receiver and the other has
TCP/IP port, and this tunneling router translates from one network to TCP/IP packets then it forwards
the messages to a PC that's running socket server application that listens constantly on a specific port, and when data is received it handles it.
gizmokaka wrote: I have a tcp/ip socket server application that receives messages threw a router.
my hardware sits on wireless network, creating messages, and pushes them to a tunneling router than in it's time push the messages to a middleware PC
with a socket server program, listening for the data.
So your "socket server" runs on the middleware PC and listens on a specific port which the router connects with and sends data.
gizmokaka wrote: when I say the connection breaks I mean, I disconnect the tunneling router from the network,
and reconnect it.
when it's reconnected it's no longer able to receive messages.
It can't receive messages from the RF devices? Or from your "socket server". Any connections that you had from your socket server to the router are dead when you disconnect the router from the network. After you reconnect the router, it must establish a new socket connection to your socket server. Are you saying it doesn't do that?
How does it initially connect to your socket server? The router must be configurable yes? Perhaps you missed a configuration property that tells it to re-connect after it detects the network presence. Or perhaps it is not capable of doing that, if not there is not much you can do.
|
|
|
|