|
Ok, I'm still mulling this over, but would it help if the values were sorted?
Say you have this:
$1 [0]
$2 [1]
$3 [2]
$4 [1]
$5 [2]
Then you sort them by values:
$1 [0]
$2 [1]
$4 [1]
$3 [2]
$5 [2]
What this buys you is that as soon as you encounter a value that doesn't equal the value you are currently searching with, you can stop the search for that value. And maybe even continue the search from that point for subconnectors.
Say you are searching with value [1]. You find the connectors $2 and $4. Then you encounter value [2]. You know at that point that you've found all of the connectors for [1].
However, did [1] have a connection to $2? Yes. So since you are already at [2], you can begin the search for $2's subconnectors from right where you are. Same goes for $4, which was also a connector for [1].
Does this help?
|
|
|
|
|
Thanks, looks better. Additionally I works with permutation now.
|
|
|
|
|
I have 10 Textboxes, textBox1 to textBox10
I have a string "naam" with contents textBox9. This 9 refers to the FOR-loop variable i
naam = "textBox" + Convert.ToString(i);
With the contents of de string-variable I would like to refer to the object with that name. I.e. textBox9.Text = ".....";
In this example I want to set de Text-property from textBox9 with the string naam
Problem: How can I refer to the name of the object textBox9 with the contents of the string naam?
Thanks
-- modified at 16:30 Sunday 20th November, 2005
|
|
|
|
|
if you just have 10 text box you can do it the long way with a switch case but it should work
ex:
<br />
switch(naam)<br />
{<br />
. case "textbox1":<br />
. TextBox1.Text="...";<br />
. break;<br />
. case "textbox2"<br />
.
}<br />
|
|
|
|
|
Let's say that you add textBox1 through textBox10 on your form. The TextBox.Name property has the string version of those stored if you use the visual form editor included in Visual Studio. So, to do what you want, if I understand your question properly, would be something like this:
int i = 9;
string naam = "textBox" + Convert.toString( i );
Control targetControl = null;
foreach( Control c in Controls )
{
if( c.Name == naam )
{
targetControl = c;
break;
}
}
if( targetControl != null )
{
}
"we must lose precision to make significant
statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
All right. Just what I meant. Works excellent. Thanks
|
|
|
|
|
My pleasure! Glad I could help you.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
I want to convert a MFC application to C#. Please help with suggestions and/or tools?
|
|
|
|
|
You really can't convert it. No automatic way of doing this. If you want your app to be written in C#, you're really going to have to rewrite it using Windows Forms.
However, I'd question why you'd want to do this. .NET is not a rewrite strategy. Unless you have significant reasons for porting your app, don't do; it'd be a lot of manual work and undoubtedly would introduce many new bugs.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Bought a House!
Judah Himango
|
|
|
|
|
As Judah Himango said, DOTNET is not really something you use just as a reason to roll out a V2 of your application.
If what you have in MFC works then keep it there.
If you want to add some new functionality then maybe you should keep it there.
If you want to add some new features that require the use of the managed code classes, or you want to really leverage the framework THEN consider a ground up re-write.
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
My Blog[^]
|
|
|
|
|
I decided to rewrite the application.
For the UI conversion there is a tool RC Convertor from www.dudelabs.com but I cannot find any other tool which can convert my business logic code from C++ to C#.Will keep you all posted with my progress.
|
|
|
|
|
|
What's this?
'A programmer is just a tool which converts caffeine into code'
|
|
|
|
|
If you need to post code containing generics (using angle brackets), please the check the "ignore html tags in this message" checkbox before you post.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Bought a House!
Judah Himango
|
|
|
|
|
I'm terribly sorry. I thought I didn't post the message...
Anyway, I answered the question I had myself.
|
|
|
|
|
I'm working to an application which use a DataBase (Access format *.mdb).
So i have a DataSet which contains a table of this DB and i want to represent it in a DataGrid...How ca i do it?
Thank You
Enrico
|
|
|
|
|
myDataGrid.DataSource = myDataSet.Tables["myTableName"];
or
myDataGrid.DataSource = myDataSet;<br />
myDataGrid.DataMember = "myTableName";
I hope you understand...because is a rough world out there...
|
|
|
|
|
hello!
i'm new here so please help me!
i'm doing a project...
i need to communicate from the computer to device whis RS232 cable
is there a class at the C# that takes care about communicating???
with not where i can found a class or someting like that???
waiting to your answers...
thank's
|
|
|
|
|
I belive the 2.0 framework has a class that allows you to talk to the serial ports. The 1.1 does not.
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
My Blog[^]
|
|
|
|
|
can you help me and search a class or something like that that i can use to communicate with the device???
|
|
|
|
|
djtourist wrote: can you help me and search a class or something like that that i can use to communicate with the device???
He did. He told you where a class was available. You just have to use Google or MSN Search to get the documentation on it. You can find it here System.IO.Ports namespace[^]
However, perhaps the pertinent words from your post are "I can use" - since you have not told us what you can use you were given the best answer available without that knowledge.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
hey thank's!
you help a lot
so actully there is a class that takes care of Serial Port!
and thank's again!
(-;
|
|
|
|
|
djtourist wrote: so actully there is a class that takes care of Serial Port!
Yes, and based on what Ray told you previously it took me less than 2 minutes to find the relevant document using MSN Search.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
i got a problem about WMI.
i want use wmi to config my network adapter, such as ip address, subnet mask, etc. and i found some methods of Win32_NetworkAdapterConfiguration class can do this, but they are all enable method, for example, EnableDNS ,it can enable DNS setting and specify dns search order.
THE PROBLEM is how can i DISABLE DNS search, namely , obtain DNS server automatically.
|
|
|
|
|
Ok i am struggling with the factory pattern big time. This pattern seems great if you are creating objects that share all the same properties but i can never find a sample client that uses the specific concrete classes that have different properteries. ( Ok that probably made no sense so here is a sample using generics )
public abstract class Vehicle
{
protected string name;
protected string type;
public Vehicle()
{
}
public Vehicle(string name)
{
this.name = name;
}
public string Name
{
get { return name; }
set { name = value; }
}
public string Type
{
get { return type; }
}
}
// a concrete vehicle
public class Car : Vehicle
{
public Car() : base()
{
}
public Car(string name, string type) : base(name)
{
base.type = type;
}
}
// another concrete vehicle
public class Truck : Vehicle
{
bool 4WD = false;
public Truck() : base()
{
}
public Truck(string name, string type) : base(name)
{
base.type = type;
}
public Engage4WD() // This only exists for a truck
{
4WD = true;
}
}
interface IVehicleFactory
{
T CreateObject<t>(string name) where T : Vehicle, new();
}
public class VehicleFactory : IVehicleFactory
{
public T CreateObject<t>(string name) where T : Vehicle, new()
{
// create instance of Type T where this type derives from Vehicle
T v = new T();
v.Name = name;
return v;
}
}
public class FactoryPatternUsingGenericMethod
{
static void Main(string[] args)
{
IVehicleFactory f = new VehicleFactory();
Car c = f.CreateObject<car>("Kitty");
Truck d = f.CreateObject<truck>("test");
}
}
}
It appears at this point i can get a truck or a car using the factory however what is the benefit of this. This just seems like alot of work when i could have just had a separate truck object and car object inheriting from vehicle and use the new operator without resorting to a factory. Would this not give the same result.
I guess i just can't seem to quite grasp what the big benefit is here for the presentation layer?
Thanks in advance
|
|
|
|