|
Hi, Dear All!
I have to sort the treenodes in my treeView.
Before sort:
-Counters
|_AAA
|_BBB
|_CCC
after the sort proceedure:
-Counters
|_CCC
|_BBB
|_AAA
I use the IComparer. The problem is: after the Node are sorted they are duplicate too.
So:
-Counters
|_CCC
|_BBB
|_AAA
|_AAA
|_BBB
|_CCC
Here is the sourcecode:
public class Form1 : System.Windows.Forms.Form
{
...
private void SortNodes(TreeNodeCollection nodes)
{
ArrayList arl = ArrayList.Adapter(nodes);
arl.Sort(new NodeComparer());
}
private void button3_Click(object sender, System.EventArgs e)
{
SortNodes(treeView2.Nodes[0].Nodes);
}
...
} //Form1
public class NodeComparer: IComparer
{
public int Compare( Object a, Object b )
{
TreeNode tn1 = (TreeNode) a;
TreeNode tn2 = (TreeNode) b;
return tn1.Text.CompareTo(tn2.Text);
}
}//NodeComparer
Could somebody tell me why are the nodes duplicated?
Thanks!
|
|
|
|
|
So, anybody, I have it now. Its not so automatical as I wanted to be, but it do what I had expected. It do reverse sort of all the Nodes of selected node. here is the code.
[CSHARP]
private void button3_Click(object sender, System.EventArgs e)
{
TreeNode sortRootNode = treeView2.SelectedNode;
int nodeCount = sortRootNode.Nodes.Count;
for (int j = 0; j < nodeCount-1; j++)
for (int i= 0; i< nodeCount-j-1; i++)
{
if(String.Compare(sortRootNode.Nodes[i].Text, sortRootNode.Nodes[i+1].Text)<0)
{
TreeNode tmpnode = sortRootNode.Nodes[i];
int index1 = sortRootNode.Nodes[i].Index;
TreeNode tmpnode2 = sortRootNode.Nodes[i+1];
sortRootNode.Nodes.Remove(sortRootNode.Nodes[i]);
sortRootNode.Nodes.Remove(sortRootNode.Nodes[i]);
sortRootNode.Nodes.Insert(index1,tmpnode2);
sortRootNode.Nodes.Insert(index1+1,tmpnode);
}
}
}
[/CSHARP]
-- modified at 4:24 Tuesday 7th March, 2006
|
|
|
|
|
Hi.
Is there anywhere to get addons for C# .net 2003? Like project solutions, Designer templates ect...?
Just wondering.
In the end we're all just the same
|
|
|
|
|
Hello,
I have a DataTable dt, And when I am trying to Select so:
dt.Select("name='ddd\'ddd'");
It returns error. How it is possible to solve this problem?
Thanks.
|
|
|
|
|
You don't need a \ because it's a single quote, not a double one.
dt.Select("name='ddd'");
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for answer. But I have in my DataTable such a row
name | value
ddd'aaa | 1.0
And I need to select: ddd'aaa. And when I type dt.Select("name='ddd'aaa'"); It returns error
For example in SQL I have to add backslash before '. In SQL it must looks like this: SELECT * FROM dt WHERE name='ddd\'aaa';
Is it possible to do the same with DataTables?
-- modified at 7:25 Monday 6th March, 2006
|
|
|
|
|
For MSSQL / Access:
dt.Select("name='ddd''aaa'");
For MySQL:
dt.Select("name='ddd\\'aaa'");
---
b { font-weight: normal; }
|
|
|
|
|
I have a button called btnSearchMP3 and I want in C# .net 2003 and I want when its clicked to display all the MP3's on a users computer in a list box called lstsearch. How would you do this?
In the end we're all just the same
|
|
|
|
|
By enumerating all drives, then recursively searching through them for files.
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() is what you need.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I understnad that. Could you give me the full code to place in the Button so when its clicked it will fill the list box?
Aslo I want if you click on the item after its found, it will open the file... how would you do that?
In the end we're all just the same
|
|
|
|
|
There's a selected item changed event on the list box, you'd use that to respond to a click on an item.
I'm not sure what you're after exactly if you know about the methods to recurse ? Do you need to know how to add an item ? It's list listBox.Items.Add, I believe.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Dave McCool wrote: if you click on the item after its found, it will open the file... how would you do that?
Store the full path of the file in the Tag object of a ListViewItem.
When an item is clicked, retrieve the tag and cast it to a string.
Then do System.Diagnostics.Process.Start(filename);
|
|
|
|
|
I have go the application working. I want whenever you right click on the item, It will bring up the context menu you get when you click on any application or file on windows. How would you do this?
In the end we're all just the same
|
|
|
|
|
Please anyone help!
I want to create web parts for sharepoint services 2.
How can I do it in visual studio 2005. When I want to open my sharepoint services page with
vs2005 it sais that vs2005 doen't support it. The sharepoint services pages are .aspx files.
Any sugestions on creating web parts in a different way is welcome.
Have tried in Frontpage 2000. Some pages worked, other gave an error after I changed it.
|
|
|
|
|
|
can any body please inform me
How to read data (digitized sound samples) from soundcard with or without using directX. and then saving to file displaying them.
desperatly waiting asap coz i am stuck with this problem......
;);P
|
|
|
|
|
Hello t4urean,
You can use this one or this one.
& still want to do some more then go here to get BASS Com object.
Best of luck .
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
thans a lot buddy. . . hope it works 4 me
happy posting
|
|
|
|
|
yep it works.... thnks 1ce agn buddy... This was a top1 4rm u..
cheers
-- modified at 9:25 Monday 6th March, 2006
|
|
|
|
|
Watch for
1)
http://www.codeproject.com/audio/VoiceRecording.asp[^]
or
2)
http://www.codeproject.com/cs/media/cswavrec.asp[^]
3)
http://www.un4seen.com/[^]
for
BASS Com object lib.
t4urean wrote: can any body please inform me
How to read data (digitized sound samples) from soundcard with or without using directX. and then saving to file displaying them.
desperatly waiting asap coz i am stuck with this problem......
|
|
|
|
|
I want to get a button to load an image icon from a DLL file. How would you do this?
How would you SAVE icon *.ico images to a dll file?
In the end we're all just the same
|
|
|
|
|
|
I have a comboBox with 12 Items in it. I want to use a If statement for each of the items, so when you choose one, something happens. Like this:
{
if (comboBox1.SelectedIndex >= 0)
MessageBox.Show("Item 1 selected");
}
Only I want an if statement for 12 items insted of one. How would I do this in C# .net 2003?
In the end we're all just the same
|
|
|
|
|
You can use switch:
switch (comboBox1.SelectedIndex) {<br />
case 1: MessageBox.Show("One"); break;<br />
case 2: MessageBox.Show("Two"); break;<br />
case 3: MessageBox.Show("Three"); break;<br />
...<br />
case 12: MessageBox.Show("Twelve"); break;<br />
}
---
b { font-weight: normal; }
|
|
|
|
|
Thats a good Idea as I did something like this in VB .net 2003 and could not in C#. Thanks
In the end we're all just the same
|
|
|
|