|
To be honest, your logic has more fundamental problems. You have two columns here which you are trying to work with, but the logic you have in the if/else only applies to one column level. What you could do is reimplement your logic like this:
foreach (DataRow dr in ds.Tables[0])
{
string colName = dr["a"].ToString();
TreeNode node = treeView1.Find(colName);
if (node == null)
{
node = treeView1.Nodes.Add(colName, colName);
}
node.Nodes.Add(dr["b"].ToString());
} What you are doing here is adding a node with a specific key into the treeview - and this key is the value of column a. You look for this node using the Find method and add it in if it doesn't exist. Finally, you add column b to the node.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
thanks for you,but when runing the code you have give me it shows:
"System.Windows.Forms.TreeView" does not contain a "Find" Definition?
|
|
|
|
|
i want get the Results like
q(father node)
..ff(child node)
..grt
..trt
..hth
w
..trt
..fgh
..hth
e
..htj
..htr
..trt
..ht
which is your changed code shown:
q(father node)
..ff(child node)
..grt
..trt
..hth
..trt
..fgh
..hth
..htj
..htr
..trt
..ht
if do this
if (pNode == null)
{ //add father node
pNode = treeView1.Nodes.Add(Row["a"].ToString());
}
else
{
TreeNode Node = pNode.Nodes.Add(Row["b"].ToString());
}
pNode=null;
shown only father node like:
q
w
e
|
|
|
|
|
table A
Field "stuage"
15 15 16 17 15 16 17 18 15 16 17 18
if do this:select * from A it show:15 15 16 17 15 16 17 18 15 16 17 18
but how can make it show:15 16 17 18,not repeat!
thanks
|
|
|
|
|
I suggest you buy a basic book on SQL and read it. And post SQL questions in the SQL forum in future.
Look up the SQL keyword 'distinct'
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I need the window form to hide itself when the user clicks [x] close button in the upper right corner.
Thus it will reside allocated and once user clicks to open it, it will just become visible again.
But upon main program termination it needs to be closed in any case.
[x] button click results in form deallocation.
Чесноков
|
|
|
|
|
HAndle the form closing event, set the flag on the event args to stop it closing, and hide it. Add your own flag that gets checked so you can close it in code.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Many thanks.
There is also CloseReason available in closing event.
In Borland Builder it was possible to define which forms should remain through out application life cycle.
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: I need the window form to hide itself when the user clicks [x] close button in the upper right corner
Is that what the user needs and expects?
Chesnokov Yuriy wrote: upon main program termination
And clicking the [x] is one way the user expects to do that.
Chesnokov Yuriy wrote: [x] button click results in form deallocation.
No it doesn't. That's up to the Application.
|
|
|
|
|
1. Which is the country hosting the 2012 Olympic Games?
(a)Portugal
(b)India
(c)South Korea
(d)England
(d)England
2. What is the largest mammal in the world?
(a)Blue Whale
(b)Elephant
(c)Camel
(d)Rhino
3. Which is the smallest ocean in the world?
(a) Arabian Ocean
(b)Pacific Ocean
(c) Artic Ocean
(d) Indian Ocean
4. The longest river in the world is the?
(a)Amazon
(b) Mississippi River
(c)Neil
(d)Brahmputra
5. The highest mountain in the world is ?
(a) Lhotse
(b) Kanchenjunga
(c) Karakoram
(d) Everest
6. The biggest desert in the world is the
(a) Arabian(Arabia)
(b) Sahara (Africa)
(c) Gobi(China)
(d) Patagonian (Argentina)
7. The largest coffee growing country in the world is
(a) Indonesia
(b) Colombia
(c) Vietnam
(d) Brazil
(e) India
8. The biggest island of the world is
a. Greenland
b. New Guinea
c. Borneo
d. Madagascar -Baffin
9. The country which is the largest producer of rubber in the world is
(a) Malaysia
(b) Thailand
(c) Zaire Republic
(d) India
|
|
|
|
|
And what has this to do with anything?
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
This is not the correct forum for these kind of posts. Try Lounge instead.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
hello every1 , am new to programming. am doin my dissertation on cd database in C#. my software should retrieve information from a cd dat is manually put into cd drive. software should copy cd info like the artist , name, song , et into a database.
This is where am stuck. am havn problems copying the cd info successfully. now my deadline is in just 1month.
This code i thought was workin.now it isnt.
PLS I NEED HELP.. AM DESPERATE..
|
|
|
|
|
Can you show the code where you are copying the CD data. And pin point the problem you are facing.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
this is the code. it gives no errors. its just not getting the contents off the cd like the album name , artist, etc.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WMPLib;
using AxWMPLib;
namespace CdRomManagement
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void axWindowsMediaPlayer1_CdromMediaChange(object sender, AxWMPLib._WMPOCXEvents_CdromMediaChangeEvent e)
{
axWindowsMediaPlayer1.currentPlaylist = axWindowsMediaPlayer1.cdromCollection.Item(e.cdromNum).Playlist;
axWindowsMediaPlayer1.Ctlcontrols.stop();
this.textBox1.Text = "Name: " + axWindowsMediaPlayer1.currentMedia.getItemInfo("Name") + Environment.NewLine;
this.textBox1.Text += "author: " + axWindowsMediaPlayer1.currentMedia.getItemInfo("author") + Environment.NewLine;
this.textBox1.Text += "Title: " + axWindowsMediaPlayer1.currentMedia.getItemInfo("Title") + Environment.NewLine;
this.textBox1.Text += "Album: " + axWindowsMediaPlayer1.currentMedia.getItemInfo("Album") + Environment.NewLine;
this.textBox1.Text += "copyright: " + axWindowsMediaPlayer1.currentMedia.getItemInfo("copyright") + Environment.NewLine;
this.textBox1.Text += "Artist: " + axWindowsMediaPlayer1.currentMedia.getItemInfo("Artist") + Environment.NewLine;
this.textBox1.Text += "Genre: " + axWindowsMediaPlayer1.currentMedia.getItemInfo("Genre").ToString() + Environment.NewLine;
this.textBox1.Text += "Bitrate: " + axWindowsMediaPlayer1.currentMedia.getItemInfo("Bitrate") + Environment.NewLine;
this.textBox1.Text += "Abstract: " + axWindowsMediaPlayer1.currentMedia.getItemInfo("Abstract") + Environment.NewLine;
this.textBox1.Text += "bitRate: " + axWindowsMediaPlayer1.currentMedia.getItemInfo("bitRate") + Environment.NewLine;
this.textBox1.Text += "duration: " + axWindowsMediaPlayer1.currentMedia.getItemInfo("duration") + Environment.NewLine;
}
}
}
|
|
|
|
|
Don't flood the whole site. Post to the right forum and stick to it.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
mimi8469 wrote: information from a cd dat
A CD and a DAT are two different formats. Which one did you mean ? Or are you just talking like a retard ?
mimi8469 wrote: now my deadline is in just 1month.
This code i thought was workin.now it isnt.
PLS I NEED HELP.. AM DESPERATE..
Why did you think it was working, and why is it not now ? I'd assume you used to connect to a database of CDs that no longer exists. Either way, it's kind of your problem. Posting a vague question like this isn't going to get you any help, you're basically asking us to redo your project, or you just plain have not thought about your post. Post some code, tell us what goes wrong, and then perhaps we can offer specific help.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
dat = that
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Please don't cross post.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
hi
in windows application , i have 3 text boxes which takes intput as decimal
now in en-US setting '.' is treated as '.' only
but in da-DK (danish Denmark) ',' is treated as '.'
and '.' is treated as ','
how to apply these settings to text boxes
i found an alternative way like this
i m replacing ',' as '.' in da-DK cuture
i know that it is not the correct way
is there any solutions for this
|
|
|
|
|
vijaylumar wrote: how to apply these settings to text boxes
They apply themselves. A textbox has no idea what you're entering, it doesn't know it's a number. int.TryParse or float.Parse, or whatever, will use the current culture.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
can you tell how to apply globalization in windows applications
thanking you
|
|
|
|
|
You can apply your chosen culture in overloaded methods if you don't want to use the default culture.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi, everybody
How to retrieve the index of items in a ListBox and
then using a loop make a statement on each element of the listbox until last.
Thank for your help
|
|
|
|
|
What have you tried ? It's very basic. Do you have any C# or winforms books ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|