|
I have 2 comboboxes :- DataType & DataFormat
In DataType if i select any type say Time/Date/IPAddress/ID i should be able to load dynamic values to DataFormat based on selected DataType.
Ex:1)DataType ->Date
DataFormat->(A)hh/mm ,(B)hh/mm/yyyy ,(C)mm/dd/yyyy .
2)DataType ->IPAddress
DataFormat ->127.000.000.000, 127.0.0.0
For DataFormat i am using a single StringConverter class.The problem here is am able to load values but always the 1st value gets replaced with selected value.What could be the reason?...
Say,i have date- hh/mm/yyyy format selected.then i change datatype as IPAddress- 127.0.0.0 .Next i come back and select date again ,at that time 1st value displayed in combobox is the selected value- hh/mm/yyyy instead of hh/mm.Now the DataFormat combobox displays duplicate values as :-
(A)hh/mm/yyyy ,(B)hh/mm/yyyy ,(C)mm/dd/yyyy .
Please help me...
|
|
|
|
|
I found a c# example that contained a for loop without any data in it but I don't understand what it means:
"for ( ; ; )"
I was always under the impression that some data needed to be included in a for loop. What does this dataless for loop achieve?
Thanks.
-Goalie35
|
|
|
|
|
It's an infinite loop. Without a break or return in the loop body, this will just loop forever. Alternative ways of doing this include while (true) or while (1 == 1).
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
This is an infinite loop construct. Some people prefer this method for certain activities over while(true) { }. In either case these are infinite loops which can cause problems. If you don't have to use them, don't. Graceful exits to loops are always preferred.
Phil
|
|
|
|
|
It's an endless loop like while (true) .
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
An endless loop. while ( true ) does the same thing, a little more clearly in my opinion. Come to think of it, maybe for ( ; true ; ) should be used.
--| "Every tool is a hammer." |--
|
|
|
|
|
Everyone is right that previously replied except for the notion that it is not infinite.
This is infinite
for(;; );
a loop with a body may or may not be infinite depending on the existence of breaks and break conditions.
for(;; ){
...
}
Also, if you are threading a Thread Abort Exception will break any infinite loop; maybe
The only reason I mention this is because there are important points to consider when writing or interpreting those kinds of structures.
File Not Found
|
|
|
|
|
Hi,
I'm one of those programmers who use for(;;) to create what some call an
"infinite loop". I have several comments on the previous entries:
1. As a long time C programmer and having used many different compilers, I dont
write code such as if (true) ... or while(true)... simply because there are compilers
that insist on generating some silly warning ("logic expression is constant" or
something similar); I expect the same for "for(;true;)" which I never tried;
I never got warnings on for(;;) so that is the only form I use; and whoever has seen
it once, knows immediately what the intentions are.
2. I dont use a semi-colon when I want an empty code block; when I need an empty code block, I write one, that is {}.
reason: those two brackets are clearly intentional and adding/deleting one of them
would result in a compilation error, whereas a single semi-colon is easily overlooked
(so it makes it harder to read and understand the code), and adding/removing one
may yield a new source that compiles, but behaves quite differently.
3. although we all know what is meant by "infinite loop", there actually is no
such thing; everything will come to an end: either energy will run out, or
someone will stop your system, or your hardware will fail, or your software
(app or OS) will crash. Guess which one it will be ?
If you are in pursuit of an infinite loop, my first recommendation would be not
to use software in it.
for(;;) Console.WriteLine("I like C#");
Luc Pattyn
[My Articles]
|
|
|
|
|
i had see the ability to do drag and drop in list view but it only for string. Can we drag and drop other than string?
|
|
|
|
|
Hi all
I am having a list<objects> (business ojects) which i need to bind to a datagridview. But the problem is it displays all the properties even if it is not set.
I way to display only specific properties is to hide those columns where the value is null.
I just want to know if there is a another way to bind specific properties only and not all the properties.
Thanx
Farhan
thanx for the support
|
|
|
|
|
hi
i want to call scanner program to scan an image (with code) and capture that image that scaned with scanner app,but how to do ?
|
|
|
|
|
Hi,
I have created and populated a generic collection.
This is the collection.
List<List<Test>> testCurves = new List<List<test>>();
How do I loop through this collection to the lowest hierarchy please?
|
|
|
|
|
foreach(List<Test> subList in testCurves)
{
foreach(Test t in subList)
{
}
}
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Just a suggestion: foreach loops are way slower than standard for loops.
|
|
|
|
|
I just tested it with a 1000*10000 nested List<List<int>> and Stopwatch -class, and this is the result:
Time for foreach-loop: 00:00:00.0980682
Time for for-loop: 00:00:00.0946116
I don't see a huge difference here.
Maybe the compiler is optimizing some things, like automatically converting it to a for-loop when it encounters a generic list.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
foreach is easier to maintain so unless you are dealing with large collections of data I always recommend foreach over a for loop. However, for truly large data you should consider pointers.
File Not Found
|
|
|
|
|
Hi all,
i am retuting an string array..but the errror is..
Cannot implicitly convert type 'string[]' to 'string'
Please help me, with a sample to return a basic array return
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
The error is telling you that you are trying to force a string array into a string. I assume that you are trying to return a string array, in which case the following will suffice:
public string[] GetValues()
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi i sorry, if any big blunders
i am very new to this kind of programming plese help me
actually i have collected some values from xml file and i need to disply them
so
i wrote
public string[] GetLaserProp(string laserid, string parentnode1, string childnode1)
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(@"E:\Dropdown_XML\laserProp.xml");
string[] str = new string[5];
// XmlNodeList xmlnodelst = xmldoc.GetElementsByTagName("laser");
XmlNodeList xmlnodelst = xmldoc.GetElementsByTagName(parentnode1);
//return xmlnodelst;
//foreach (XmlNode.parentnode in xmlnodelst)
foreach (XmlNode parentnode in xmlnodelst)
{
//MessageBox.Show(parentnode.Attributes.Item(0).Value);
if (parentnode.Attributes.Item(0).Value == laserid)
{
xmldoc.LoadXml(parentnode.InnerXml);
//XmlNodeList xmlchildnodelst=xmldoc.GetElementsByTagName("gauge");
XmlNodeList xmlchildnodelst = xmldoc.GetElementsByTagName(childnode1);
// cmbChildLaser.Items.Clear();
foreach (XmlNode childnode in xmlchildnodelst)
{
for (int i = 0; i < childnode.ChildNodes.Count; i++)
{
//cmbChildLaser.Items.Add(childnode.ChildNodes.Item(i).Attributes.Item(0).Value);
for (int j = 0; j < childnode.ChildNodes.Item(i).Attributes.Count; j++)
{
// MessageBox.Show(
str[j]= childnode.ChildNodes.Item(i).Attributes.Item(j).Value;
//cmbChildLaser.Items.Add(xmlnodelst1.Item(ii).ChildNodes.Item(0).InnerText);
return str;
}
}
}
}
}
//return (Student []) students.ToArray();}
return str;
prashanth,
s/w Engineer,
Syfnosys.
|
|
|
|
|
Gosh! That code is very difficult to read because of all the commented out lines. This can be quite confusing.
Here is a cleaner version of the code you've supplied:
public string[] GetLaserProp(string laserid, string parentnode1, string childnode1)
{
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(@"E:\Dropdown_XML\laserProp.xml");
string[] str = new string[5];
XmlNodeList xmlnodelst = xmldoc.GetElementsByTagName(parentnode1);
foreach (XmlNode parentnode in xmlnodelst)
{
if (parentnode.Attributes.Item(0).Value == laserid)
{
xmldoc.LoadXml(parentnode.InnerXml);
XmlNodeList xmlchildnodelst = xmldoc.GetElementsByTagName(childnode1);
foreach (XmlNode childnode in xmlchildnodelst)
{
for (int i = 0; i < childnode.ChildNodes.Count; i++)
{
for (int j = 0; j < childnode.ChildNodes.Item(i).Attributes.Count; j++)
{
str[j]= childnode.ChildNodes.Item(i).Attributes.Item(j).Value;
return str;
}
}
}
}
}
return str;
}
Which line contained the error, because I cannot see anything here that would cause the error. Perhaps, as Pete suggested, the error is in the caller.
|
|
|
|
|
Colin Angus Mackay wrote: Which line contained the error, because I cannot see anything here that would cause the error.
Me neither
Colin Angus Mackay wrote: Perhaps, as Pete suggested, the error is in the caller.
agreed
modified 12-Sep-18 21:01pm.
|
|
|
|
|
You force your array to have a size of 5. What happens if you have more than 5 matches?
If you're using .NET 2, you would be better using this:
public List<string> GetLaserProp(string laserid, string parentnode1, string childnode1)
{
List<string> list = new List<string>();
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(@"E:\Dropdown_XML\laserProp.xml");
XmlNodeList xmlnodelst = xmldoc.GetElementsByTagName(parentnode1);
foreach (XmlNode parentnode in xmlnodelst)
{
if (parentnode.Attributes.Item(0).Value == laserid)
{
xmldoc.LoadXml(parentnode.InnerXml);
XmlNodeList xmlchildnodelst = xmldoc.GetElementsByTagName(childnode1);
foreach (XmlNode childnode in xmlchildnodelst)
{
for (int i = 0; i < childnode.ChildNodes.Count; i++)
{
for (int j = 0; j < childnode.ChildNodes.Item(i).Attributes.Count; j++)
{
list.Add(childnode.ChildNodes.Item(i).Attributes.Item(j).Value);
}
}
}
}
}
return list;
}
-- modified at 10:05 Wednesday 7th March, 2007
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Why not using a List<string> ?
---
single minded; short sighted; long gone;
|
|
|
|
|
I did, but the formatting got stripped out. (Show's I should preview my posts). I'll fix it ASAP.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi
I am developing a windows application in which it contains a grid. on double clicking a row on the Grid it shows all the details about that row in a new form.
If i double click the same row or other row it opens the details of respective row again in a same form.
For this i followed one logic. I take a global variable (public boolean X= false) and i am setting it true when user double clicks a row. I am resetting it in the child form. Here the value is not resetting.
What i want is Is there any mechanism or statements of code to preventing the form from openning more than one form at a time.
Please Help me.
Thanks in Advance.
Ramu Medida.
|
|
|
|