|
Another thing that's confusing about it is that the stack trace looks like it's the GUI thread that's being aborted...but that's certainly not the case.
|
|
|
|
|
i created a design with labels, textboxes and
(dropdownbox in list format) but do not know how to make my dropdownbox be in databinding instead of list format.
|
|
|
|
|
Here[^] is something you need to read.
Any control that can be databound, has a DataSource property. Set it to any valid source, such as a string array, or a list.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I thought maybe it was a datatype conflict and i checked the data type and the 2 variables are of the same data type but even when the conditions true, the if loop is not executed. heres the code and they are saved in 3 different files and here i am using interface to implement an ADT. And i am executing this code in Visual C# 2008 express edition. Can someone help e with this please, check he if condition.
<pre>
// File Name: ISet.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public interface ISet
{
int Cardinality
{
get;
}
void Add(Object element);
void Remove(Object element);
}
//File Name: Set.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class Set:ISet
{
private Object[] set1;
public int MAX = 20;
private int cardinality;
public Set()
{
this.set1 = new Object[MAX];
this.cardinality = 0;
}
public int Cardinality
{
get
{
return this.cardinality;
}
}
public void Add(Object element)
{
this.set1[this.cardinality] = element;
cardinality++;
}
public void Remove(Object element) //convert the set[i] to interger
{
Console.WriteLine("the element to be removed"+element);
for (int i = 0; i < this.cardinality; i++)
{
Console.WriteLine("The element in the set" + set1[i]);
Console.WriteLine("The element passed as the parameter" + element);
Console.WriteLine(set1[i].GetType());//checking the datatype;
Console.WriteLine(element.GetType());
if(set1[i] == element)
{
Console.WriteLine("The element to be removed found!!");
//This statement is not executed even when the condition is true!!!!!!
}
} //closing for loop
} // function end
} //end of the class
//File Name : Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
static void Main(string[] args)
{
Set set1 = new Set();
Console.WriteLine("The number of items in the set:" + set1.Cardinality);
set1.Add(5);
Console.WriteLine("The number of items in the set:" + set1.Cardinality);
set1.Remove((5));
}
}
</pre><pre></pre><pre></pre><pre></pre><pre></pre>
|
|
|
|
|
|
so sorry about that i was referring to if condition?? somehow when the if condition is true the statement "The element to be found!" should have printed but it is not doing so. Is something wrong with the compiler? because the code looks fine to me too.
|
|
|
|
|
set1[i] == element
I suspect this isn't doing what you want; perhaps element.Equals ( set1[i] ) will do it.
|
|
|
|
|
I'm working on a set of classes to simplify the use of sockets, however I have a problem: I don't know how to use sockets. Does anyone know of some good, easy to understand tutorials for server end and client end sockets?
Thanks.
|
|
|
|
|
How can you simplify something you don't know how to use? That's like saying I'm trying to simplify using a screwdriver, but I don't know what a screw is.
Anyway, search for articles on CP and google.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
If I can find a good tutorial on sockets I can create a set of classes to simplify the use and creation of sockets which I can use in the future.
|
|
|
|
|
Hello,
Is it possible to close a messageBox automaticly after few seconds?
Any one can help me?
Thanks
PC
|
|
|
|
|
You could but it would involve making your own class to use as a messagebox because the MessageBox class is static so you can inherit it and when you show it the code stops till you click OK.
Feel free to prove me wrong anyone.
|
|
|
|
|
Your best bet is just to write your own messagebox that does this.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Let me try to explain the my problem with my bad english...
I have an aplication that runs a process in background and i was forced to stop the execution of the aplication until this process is complete, but this process could long for large seconds. So i must have a way to warn the user to wait, i thougt in a messageBox , and i do it, but than this messageBox stays until the user clicks ok, not until the end of the process.
I have tried with a form but it does not work to well. The form stays full of holes (the places where it should load the labels).
Could you sugest me other solution or a way to solve the problem with the form?
thanks for your help.
PC
|
|
|
|
|
So you're using two seperate threads. Using the other thread (not the background one) create a timer that will tick after say a minute. When it ticks check to see if the background thread is still running. If it's still running show the messagebox. Even when the box is open the other thread will still run.
|
|
|
|
|
Yes, you are rigth i'm following your advice, but it still not perfect because if the thread that runs in background ends, and the user dont press OK before, i will have the messageBox in the screen but the program its already in another fase (since its a caind of Wizard).
But i think i must live with that because i don´t find a better answer.
Perhaps i should follow your 1st advice and built my one class for the messageBox.
Thanks for the help
PC
|
|
|
|
|
|
thanks for the tip, that code seems very helpfull and its a better solution that the messageBox.
Many thanks
PC
|
|
|
|
|
One way is to create your own form with an OnTimer event. The form can be just a label that you assign text to prior to showing it. Then the OnTimer event can call this.close();
|
|
|
|
|
I have already solved that problem, just like you sugest...
Thank you
PC
|
|
|
|
|
Had a lot of trouble finding an easy way to accomplish this; thought I would pass this code on.
I wrote a program called SatAmp that has a WebControl http page it sends out for external control of the application, and I wanted a way to help people find their external IP Address from the program itself without requiring them to actually visit a website for the purpose.
Here is my solution:
<br />
using System;<br />
using System.IO;<br />
using System.Net;<br />
using System.Text;<br />
<br />
namespace SatAmp.Utility_Classes<br />
{<br />
class IPRequest<br />
{<br />
public static string GetIP()<br />
{<br />
StringBuilder sb = new StringBuilder();<br />
<br />
byte[] buf = new byte[8192];<br />
<br />
HttpWebRequest request = (HttpWebRequest)<br />
WebRequest.Create("http://www.whatismyip.com/automation/n09230945.asp");<br />
<br />
HttpWebResponse response = (HttpWebResponse)<br />
request.GetResponse();<br />
<br />
Stream resStream = response.GetResponseStream();<br />
<br />
string tempString = null;<br />
int count = 0;<br />
<br />
do<br />
{<br />
count = resStream.Read(buf, 0, buf.Length);<br />
<br />
if (count != 0)<br />
{<br />
tempString = Encoding.ASCII.GetString(buf, 0, count);<br />
<br />
sb.Append(tempString);<br />
}<br />
}<br />
while (count > 0);
<br />
<br />
return sb.ToString();<br />
}<br />
<br />
<br />
}<br />
}<br />
<br />
<br />
<br />
<br />
public void buttonGetMyIP_Click(object sender, EventArgs e)<br />
{<br />
try<br />
{<br />
string ip = IPRequest.GetIP();<br />
<br />
this.labelMyIpAddress = ip;<br />
}<br />
catch<br />
{<br />
this.labelMyIpAddress = 000.000.000.000;<br />
}<br />
}<br />
|
|
|
|
|
How can i find a child object location within it's parent container. Thanks
|
|
|
|
|
netJP12L wrote: How can i find a child object location within it's parent container
I think you're going to need to elaborate a little bit.
Are you talking about the location of a control on a form? The location of a control within another control? The the index of an item in an array, List<>, or other collection?
|
|
|
|
|
Does the parent container have a find method ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
You're as bad as my partner's children..... try looking for it!
|
|
|
|