|
well the WinCE 4.2 is stable only with .net 1.0 and with 2.0 there seems to be some issues, thanks I will try your method and see how it works
|
|
|
|
|
I am creating a menu control. It is having property called Items similar to ListItem . MenuItem class contains MenuName , MenuText , Image properties. User can add any number of menu items. So I created MenuItemCollection class which extends CollectionBase . It's having add method which accepts MenuItem class objects. Everything worked fine when adding from code behind. It looks like
MenuItemCollection MnuCollection = New MenuItemCollection();
MnuCollection.Add(MenuItemObject)
But problem started when I given collection class to the Items property to let user add menu items at design time, like what listbox do.VS Editor is showing collection at the Items Property. But when I click on Items, it opens collection editor also. But after clicking new it's simply showing System.Object . It's not showing any properties written in the MenuItem class. Can any one throw some light into this problem ? How I can create a collection class in user control and set that to the property, where user can add items at design time ?
|
|
|
|
|
If you are using .net >= 2.0 then I suggest you use a generic collection for your MenuItems:
public List<MenuItem> MenuItems
{
get { ... }
set { ... }
}
-^-^-^-^-^-
no risk no funk
|
|
|
|
|
Urs Enzler wrote: public List <MenuItem> MenuItems
Thanks, But I am not clear with this line, what do you mean by this ? By specifying <MenuItem> will this show properties in MenuItem class on CollectionEditor ?
|
|
|
|
|
I receive a format exception message when i run this program.
the code is as follow:
string latitude1, latitude2;
string longitude1, longitude2;
latitude1 = label9.Text;
longitude1 = label10.Text;
label9.Text = textBox1.Text.ToString();
label10.Text = textBox2.Text.ToString();
latitude2 = label9.Text;
longitude2 = label10.Text;
if ((latitude1 != latitude2) || (longitude1 != longitude2))
{
double lat1 = Convert.ToDouble(latitude1);
double long1 = Convert.ToDouble(longitude1);
//double lat1 = 1.346094;
//double long1 = 103.932421266667;
double lat2 = Convert.ToDouble(latitude2);
double long2 = Convert.ToDouble(longitude2);
double lat1r = lat1 * (Math.PI / 180);
double long1r = long1 * (Math.PI / 180);
double lat2r = lat2 * (Math.PI / 180);
double long2r = long2 * (Math.PI / 180);
double latitude = lat2r - lat1r;
double longitude = long2r - long1r;
double a = Math.Pow(Math.Sin(latitude / 2.0), 2.0) + Math.Cos(lat1r) * Math.Cos(lat2r) * Math.Pow(Math.Sin(longitude / 2.0), 2.0);
double c = 2.0 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1.0 - a));
const Double earthRadius = 6376.5;
distance = earthRadius * c;
}
totalDistance = totalDistance + distance;
label4.Text += totalDistance.ToString();
the exception came in at double lat1 = Convert.ToDouble(latitude1);
so i edited the code to:
string latitude1, latitude2;
string longitude1, longitude2;
latitude1 = label9.Text;
longitude1 = label10.Text;
label9.Text = textBox1.Text.ToString();
label10.Text = textBox2.Text.ToString();
latitude2 = label9.Text;
longitude2 = label10.Text;
if ((latitude1 != latitude2) || (longitude1 != longitude2))
{
if (latitude1!="" || longitude1!="")
{
double lat1 = Convert.ToDouble(latitude1);
double long1 = Convert.ToDouble(longitude1);
//double lat1 = 1.346094;
//double long1 = 103.932421266667;
double lat2 = Convert.ToDouble(latitude2);
double long2 = Convert.ToDouble(longitude2);
double lat1r = lat1 * (Math.PI / 180);
double long1r = long1 * (Math.PI / 180);
double lat2r = lat2 * (Math.PI / 180);
double long2r = long2 * (Math.PI / 180);
double latitude = lat2r - lat1r;
double longitude = long2r - long1r;
double a = Math.Pow(Math.Sin(latitude / 2.0), 2.0) + Math.Cos(lat1r) * Math.Cos(lat2r) * Math.Pow(Math.Sin(longitude / 2.0), 2.0);
double c = 2.0 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1.0 - a));
const Double earthRadius = 6376.5;
distance = earthRadius * c;
}
}
totalDistance = totalDistance + distance;
label4.Text += totalDistance.ToString();
adding another if condition to solve the exception, although the format exception was handled. the end result of what was expected is not there. the totalDistance calculated show me an answer that display infinity.
any idea how i can solve this problem
|
|
|
|
|
Hello,
And you had no time to make a little debugging, to tell us the point where the exception occures?
Sorry just saw, that you gave some infos.
But it is very difficult to see, as you are not using the pre tags to mark the code!
I would think, this is very dangerous!
Convert.ToDouble(latitude1); Use "double.TryParse" instead!
And that's the reason of the exception:
latitude1 = label9.Text;
longitude1 = label10.Text;
label9.Text = textBox1.Text.ToString();
label10.Text = textBox2.Text.ToString();
Looks like label Text is empty when you pathit to the string field.
label9.Text = textBox1.Text.ToString();
label10.Text = textBox2.Text.ToString();
latitude1 = label9.Text;
longitude1 = label10.Text;
-- modified at 5:06 Thursday 26th July, 2007
All the best,
Martin
|
|
|
|
|
How would this be dangerous?
Convert.ToDouble(latitude1);
i did try using double.TryParse() but it doesn't work. The end result is still infinity.
latitude1 = label9.Text;<br />
longitude1 = label10.Text;<br />
<br />
label9.Text = textBox1.Text.ToString();<br />
label10.Text = textBox2.Text.ToString();<br />
<br />
latitude2 = label9.Text;<br />
longitude2 = label10.Text;
i did it in this way because whenever a new coordinate(latitude, longitude) is received, it will replace the variable that is either of old value being stored or empty value currently.
|
|
|
|
|
Let's suppose for a moment your program contains more than one mistake.
You will have to fix them all.
It is unlikely that fixing the first one will solve all problems, since by
assumption there are multiple problems.
But still, the first mistake needs fixing.
So why do you ask for advice, then choose to ignore perfectly good advice
Anyhow if some system does not behave the way you intended, there are two ground rules:
1. observe, observe closely, observe even more closely; so dont look at the end result,
it is wrong and it will be wrong for a long time.
2. if you dont understand the overall thing, reduce the size; make sure that part works
perfectly under all circumstances; then investigate another part, etc; when all parts
SEEM OK, now look at the whole thing again.
Such is called debugging, whatever the tools you use.
|
|
|
|
|
|
I want to read data from a hardware device like time access punching machine.
What is the complete process to read data and storing into a databse from any hardware device.
If any one have some idea, please guide me.
Thanks,
Pathak
|
|
|
|
|
I am using FolderBrowserDialog to Browse for folder
I want to show the address in textbox also which I select in FolderBrowserDialog
or can directly type the address of folder in textbox instead of selecting it from tree view control
FolderBrowserDialog obj=new FolderBrowserDialog();
obj.ShowNewFolderButton=true;
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
Hi sweety , it's very easy . enjoy it :
// Initialize FolderBrowserDialog
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
// If dialogResult result is OK then set txtAddress by folderBrowserDialog
// SelectedPath's property .
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
string selectedPath = folderBrowserDialog.SelectedPath;
txtAddress.Text = selectedPath;
}
have a good time.
DMASTER
|
|
|
|
|
I want it on folder browser dialog which gets opened on clicking browse button
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
anyone knows how to change the directory of one file from ftp using c#.net?
please help.
thanks
|
|
|
|
|
Hi,
I want the equivalent of WithEvents (VB) in C#.
I want the equivalent of this line
VB :
Dim WithEvents theCL As TOMListenerCall
C# : ???
thank you for your answer
zinzineti
|
|
|
|
|
zinzineti wrote: VB :
Dim WithEvents theCL As TOMListenerCall
C# :
TOMListenerCall theCL;
|
|
|
|
|
I do
TOMListenerCall theCL;
And in my form.cs at InitializeComponent() i put this code :
this.theCL.onEstablished +=new ITOMListenerCallProxy_onEstablishedEventHandler(theCL_onEstablished);
but I have this error : La référence d'objet n'est pas définie à une instance d'un objet.
Thanks for your answer
|
|
|
|
|
You should not be changing InitializeComponent manually. This is where autogenerated code goes and will be re-generated by the IDE.
The code you posted does not create a new instance of TOMListenerCall, it simply declares a variable (WithEvents) of that type. That is exactly the same as the code I translated to C# for you.
In order for you to use an Instance of that object (ie, to subscribe to events) you must create a new instance using the new keyword. As I do not know whhat constructors TOMListenerCall defines, ill assume it has a parameterless constructor:
<br />
TOMListenerCall theCL = new TOMListenerCall()<br />
theCL.onEstablished +=new ITOMListenerCallProxy_onEstablishedEventHandler(theCL_onEstablished);
|
|
|
|
|
hi
is there any way to keep an array list of points in an area? i need to do this to use the points for checking if the mouse click event is in the area.
thanks
|
|
|
|
|
What are you doing here?
You posted the questions three times now, and allways provide a little less information.
And now this, no information at all!
All the best,
Martin
|
|
|
|
|
I'm sorry, i don't intend to be rude. i thought i gave enough informations. I'm just trying my best to learn, sorry...
|
|
|
|
|
F*** U...
If U don't want to answer his question, then U must shut Your f***Mouth
|
|
|
|
|
I really like the combination of, marking a post as "Joke" and all the f words in it.
I also wish you a nice day and thank you for your nice words!
All the best,
Martin
|
|
|
|
|
Point number 8 in all forums' administrative post reads like this:
<big>Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.</big>
|
|
|
|
|
Hmmm. lets review your contribution of 3 whole posts to CodeProject:
UglyxXXx wrote: f*** U...
Hei U buy by your self a**hole
UglyxXXx wrote: f*** U...
f*** U Christian...
If U dont want to answer his question, then dont answer it
UglyxXXx wrote: f*** U...
If U don't want to answer his question, then U must shut Your f***Mouth
Can I be the first top invite YOU to get lost?
|
|
|
|