|
GetItemAt is not throwing the exception, selection.Text is. GetItemAt expects client coordinates (i.e. where the mouse cursor is). Use list1.Items and list1.Items[x].SubItems to access the values.
Josh
|
|
|
|
|
Dude, you are my new-found HERO!
Thanx Josh! Exactly what I wanted
Willem Le Roux
-- modified at 5:02 Wednesday 21st June, 2006
|
|
|
|
|
hello, I`m using this code, but it return files in alphabetic order, I need to list those files in date modified order.
string winDir = "../katalogas";
try
{
string[] files = Directory.GetFiles(winDir);
foreach (string fileName in files)
{
//
//
}
}
catch (IOException ex)
{
MessageBox.Show("Klaida! Nerandamas formų katalogas." + ex.Message);
Close();
}
}
|
|
|
|
|
I believe that it doesn't return the files in any specific order at all. They just happen to be ordered alphabetically in the directory. Probably because you have moved the folder (as that creates a new folder and moves the files) or have run defrag (which sorts the files in the directories).
You need to get more information about the files than just the name. Use DirectoryInfo.GetFiles to get FileInfo-object for the files.
Make a Comparer for two FileInfo-objects that compares the property you want to sort on, and use that in the Array.Sort method.
---
b { font-weight: normal; }
|
|
|
|
|
hai all,in my application i enter the user details in to the database and other details in the form of word document(using html file field),when i delete the user, it delete only the user information from the database but i need to delete the respective word document also (when i delete the respective record from the database).is it possible...?..if so tell me how to do this....
Regards,
ayyp
-- modified at 8:48 Tuesday 20th June, 2006
|
|
|
|
|
Can anyone help solve the following problem
Create a console application that prints all possible combinations of the number from 1 - 9 that equals 10. IE 1+1+1+1+1+1+1+1+1+1=10 AND 1+1+1+1+1+1+1+1+2=10 etc..
rules that apply:
3 + 7 = 10 and 7 + 3 = 10... both is not allowed, only one of those sums are required.
how do you do it?
|
|
|
|
|
izakfick wrote: how do you do it?
I'd do my own homework
|
|
|
|
|
izakfick wrote: how do you do it?
By reading back over you notes from class, and refering to the course material you have been given.
ie/ do you own homework! Or at very least show us what you've tried and what specific problem you are having!
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
now ain;t that a friendly answer, just say so if you don;t know..
this is what i've got so far. hey I'm trying and this isn;t for class cupid.
class Class1
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
int[] intArray = {1,2,3,4,5,6,7,8,9};
Calculate c = new Calculate();
for(int a = 1; a < intArray.Length; a++)
{
for(int b = 1; b < intArray.Length; b++)
{
string output = c.calc(a,b);
if(output!="")
{
Console.WriteLine(output);
}
}
}
string stop = "";
}
}
public class Calculate
{
public string calc(int x, int y)
{
int iTotal = 0;
string s_out = "";
while(iTotal < 10)
{
iTotal = iTotal + x + y;
s_out = s_out + x.ToString() + " + " + y.ToString() + " + ";
if(iTotal == 10)
{
s_out = s_out.Substring(0,s_out.LastIndexOf("+")-1) + " = " + iTotal.ToString();
}
}
if(iTotal>10)
{
s_out = "";
}
return s_out;
}
}
|
|
|
|
|
Well .. the solution is very simple ... I am sure J4amieChowever, show us that you tried something atleast.
Jedi
|
|
|
|
|
still busy trying, but some help would be great, thinking of using a hashtable to put in entries and also do reverse string entry checks to prevent the applicable rules that apply.
thank you.
|
|
|
|
|
The solution to your addressed question is a simple check in the the second for loop, set b=1 rather than 1.
However the remaining code in your application does little to generate all possible solutions.
Jedi
|
|
|
|
|
OK I'm now left with less results but results that applies to the rules
class Class1
{
[STAThread]
static void Main(string[] args)
{
int[] intArray = {1,2,3,4,5,6,7,8,9};
Calculate c = new Calculate();
CheckHash ch = new CheckHash();
Hashtable hash = new Hashtable();
for(int a = 1; a < intArray.Length; a++)
{
string output = c.calc(a,a);
if(output!="")
{
if(!ch.Check(hash,output))
{
Console.WriteLine(output + " = 10");
hash[hash.Count] = output;
}
}
for(int b = 1; b < intArray.Length; b++)
{
output = c.calc(a,b);
if(output!="")
{
if(!ch.Check(hash,output))
{
Console.WriteLine(output + " = 10");
hash[hash.Count] = output;
}
}
}
}
string stop = "";
}
}
public class Calculate
{
public string calc(int x, int y)
{
int iTotal = 0;
string s_out = "";
while(iTotal < 10)
{
iTotal = iTotal + x + y;
s_out = s_out + x.ToString() + " + " + y.ToString() + " + ";
if(iTotal == 10)
{
s_out = s_out.Substring(0,s_out.LastIndexOf("+")-1);
}
}
if(iTotal>10)
{
s_out = "";
}
return s_out;
}
}
public class CheckHash
{
public bool Check(Hashtable hsh,string s_in)
{
bool bTrue = false;
string ReverseString = "";
char[] arrays = s_in.ToCharArray();
for(int a = s_in.Length - 1; a >= 0;a--)
{
ReverseString = ReverseString + arrays[a];
}
if(hsh.ContainsValue(s_in))
{
bTrue = true;
}
if(hsh.ContainsValue(ReverseString))
{
bTrue = true;
}
return bTrue;
}
}
I'd like some help now
|
|
|
|
|
ok i showed my @#$ contribution
|
|
|
|
|
Gimme a few more mins ... working on a recursion solution.
Jedi
|
|
|
|
|
cheers, still busy myself
|
|
|
|
|
using System;
namespace ConsoleApplication2
{
///
/// Summary description for Class1.
///
class Class1
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
Calculate c = new Calculate();
c.initCalc();
System.Console.WriteLine ("Done");
System.Console.Read ();
}
}
public class Calculate
{
int[] intArray = {1,2,3,4,5,6,7,8,9};
public void initCalc()
{
string s_out = "";
int iTotal = 0;
int j=0;
for(int i = 0; i < intArray.Length; i++)
{
iTotal = intArray[i];
s_out = intArray[i].ToString() + " + ";
j=i;
calc(intArray, j, s_out, iTotal);
}
}
public string calc(int[] intArray, int j, string s_out, int iTotal)
{
String s_out2;
if(iTotal == 10)
{
s_out = s_out.Substring(0,s_out.LastIndexOf("+")-1) + " = " + iTotal.ToString();
Console.WriteLine(s_out);
}
while(iTotal < 10 && j<intarray.length)
{
="" itotal="iTotal" +="" intarray[j];
="" s_out2="s_out;
" s_out="s_out" intarray[j].tostring()="" "="" ";
="" calc(intarray,j,s_out,="" itotal);
="" -="" j++;
="" }
="" if(itotal="">10)
{
s_out = "";
}
return s_out;
}
}
}
Jedi
|
|
|
|
|
cheers jedi,
i can see 42 out of 98 possiblities...
you've helped me a lot, cheers
|
|
|
|
|
The program i wrote should give you all distinct possibilities ... what do you mean 42 out of 98?
|
|
|
|
|
you're right, these guys are mistaken by 98...
i've checked and it's absolutely correct.
Thank you
|
|
|
|
|
If it's not a class assignment, you should have made that clear from the beginning. It looks very much lika a class assignment.
I would solve it recursively. Make a method that creates all combinations to get the sum "n" by looping a number and use itself to get all combinations to fill the difference between the number and "n".
---
b { font-weight: normal; }
|
|
|
|
|
class Program
{
static void Main(string[] args)
{
Program pg = new Program();
pg.allTenSum();
Console.ReadLine();
}
public void allTenSum()
{
int check = 0;
string add = "";
int[] a ={ 1, 2, 3, 4, 5, 6, 7, 8, 9 };
List<string> val = new List<string>();
foreach (int abc in a)
{
for (int m = abc; m < 10; m++)
{
if ((m + abc) <= 10)
{
add = Display(abc, m);
foreach (string disp in val)
{
if (disp == add)
check = 1;
}
if (check != 1)
{
if (add != "")
val.Add(add);
}
}
}
}
foreach (string disp in val)
{
Console.WriteLine(disp);
}
}
public string Display(int a, int b)
{
int testTen = 0;
string str = "";
str = str + b + "+" + a;
testTen = testTen + a + b;
while ((testTen + a) < 10)
{
if (str == "")
{
str = str + a;
}
else
{
str = str + "+" + a;
}
testTen = testTen + a;
}
if ((10 - testTen) != 0)
{
int k = 10 - testTen;
str = str + "+" + k;
}
return str;
}
}
Output is :
1+1+1+1+1+1+1+1+1+1
2+1+1+1+1+1+1+1+1
3+1+1+1+1+1+1+1
4+1+1+1+1+1+1
5+1+1+1+1+1
6+1+1+1+1
7+1+1+1
8+1+1
9+1
2+2+2+2+2
3+2+2+2+1
4+2+2+2
5+2+2+1
6+2+2
7+2+1
8+2
3+3+3+1
4+3+3
5+3+2
6+3+1
7+3
4+4+2
5+4+1
6+4
5+5
|
|
|
|
|
hi all,
i want to create a windows form where-in i want to get the list all web methods found within a webservice, in a list box, by giving the url of the .asmx file as input. iv got slight idea that i need to use the "System.Web.Services.Discovery" and "System.Web.Services.Description" namespaces for this....
but have no idea as to how to proceed further and get my requirement completed!!!!
If any one could help me with a piece of sample code it would be of great use!!!
Thanks in advance!!1
regards
Compdesign..
|
|
|
|
|
|
I am working on a windows application .This application will be running in the background and capturing all the keystrokes .All the short-cut keys need to be disabled i.e. Alt+F4 or windows+M etc by this application.If the user presses alt+ctrl+8 he should be shown a login screen and if he is authorised the keys should be enabled according to his permission level i.e Admin ,user etc. If this application has got the focus then only it captures events , but as the case mostly is ,there is some other application running which will have focus but I still want to get these keystroke events in my application .Any help please.
Thank you.
|
|
|
|