|
Hello Everybody,
I want to create a List for Parent Child Information. So I want to know that what is the best Object for Store Information of Parent Child.
I am confused with :
Arraylist, IList,List,Distionery or
else in your mind.
If you have any example then your most welcome to share your knoledge.
Thanks
If you can think then I Can.
|
|
|
|
|
A List .
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Hello John,
Thanks for your suggession. Can u please help me How Can i Create a class that contain the information of Parant and Childs.
Thanks
If you can think then I Can.
|
|
|
|
|
As JSOP says, a List is probably the best.
However, there is the TreeNode class[^] which is used as part of teh TreeView class - this is already configured with Parent and Nodes properties, so it may be worth investigating.
If nothing else, they are easy to display - just add them into a TreeView...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
This would probably be the best way, but the parent/child relationship is kinda tenuous, and there's a lot of stuff in the TreeNode class that you don't need unless the collection is being displayed in a tree control. I think a carefully designed List would be more performant overall.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Thanks for ur suggession,
But i can't use treeview control because i am creating library without using Windows.Forms Controls .So pls help me for How i can work same as treeview.
Thanks
If you can think then I Can.
|
|
|
|
|
Try:
public class myTree
{
public myTree Parent {get; private set;}
public List<myTree> Children { get; private set;}
public myTree(myTree parent)
{
Parent = parent;
Children = new List<myTree>();
}
}
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
A List is very appropriate in this case. The other option is to create your own class.
|
|
|
|
|
The create your own class is a simple and nice implementation where the class contains a collection of children. That way the selected item contains pointers to the children, lazy or otherwise.
"You get that on the big jobs."
|
|
|
|
|
Yes, and I always prefer creating my own classes in such situations unless they're very trivial. Creating your own class gives you the freedom to model the class according to your requirements, decide between early and lazy loading children, restrict the type of children and their numbers to be added to a specific instance of the class, etc. With stock collection classes like List and Dictionary , you're forced to do this in an inefficient and ugly way.
|
|
|
|
|
What features should it have? If you want to easily get children from parent then a Dictionary<parent,List<child>> might be good, if you want to easily get parent from child, then a Dictionary<child,parent> might be good. If you want both, then you will likely want something custom.
|
|
|
|
|
You want a tree. A simple tree (with a single root node) can be created with a class like this:
class TreeNode {
IList<TreeNode> Children { get; private set; }
public TreeNode(){
Children = new List<TreeNode>();
}
}
If you want two way linkage you can do
class TreeNode {
IList<TreeNode> Children { get; private set; }
TreeNode Parent { get; private set; }
public TreeNode(TreeNode parent){
Children = new List<TreeNode>();
if(parent != null) parent.Children.Add(this);
Parent = parent;
}
}
Just store the tree through its root node, unless you want to store other metadata with the tree, in which case you can have a class like
class Tree {
TreeNode Root { get; private set; }
public Tree(TreeNode root){
Root = root;
}
}
|
|
|
|
|
Hello,
One of my friend ask me about how to use binding on multiple data sources.
Please help me to answer, as I am a newbie in .net programming.
|
|
|
|
|
This is gonna blow your mind:
9.7 MILLION google results for "bind control to multiple data sources"[^]
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
I'm not sure I understand what you're asking. If you're talking about binding multiple data sources to a single control, I'm not sure it can be done without writing a custom control. For example, a select list can only have one data source. On the other hand, a custom control can have any number of elements that can be bound to their own individual data sources.
Scott E. Corbett
Software Engineer/Analyst
|
|
|
|
|
I also think so about binding multiple data source, its not possible without custom controls, because one control can have only one data source. Recently I found a custom control which can do all these and can also used for other purposes e.g. real time data updation, performance and so on, here is the website http://www.dapfor.com/Feature.aspx[]
|
|
|
|
|
robertalis wrote: One of my friend ask me about how to use binding on multiple data sources.
And how does that make you feel?
|
|
|
|
|
Hi,
when I select a particular node in the xml, I should be able to display all its ancestors's Token values.
For example, for the Token:"ANA", output should be "PROD,BUSINESS,COS"
for the Token:"DRGPATENT", output should be "PROD,BUSINESS"
I tried to get the immediate parent by using below code. Pls guide me to get all its ancestors. Thanks in advance
foreach (XPathNavigator book in topicsXml.CreateNavigator().Select("//Entity"))
{
string parent = book.SelectSingleNode("../Token").Value;
}
<CodeList>
<Entity>
<Token>PROD</Token>
<Description>prod</Description>
<Entity>
<Token>BUSINESS</Token>
<Description>Business News</Description>
<Entity>
<Token>COS</Token>
<Description>Company News</Description>
<Entity>
<Token>ANA</Token>
<Description>Analyst Ratings</Description>
<Entity>
<Token>ANAMOVES</Token>
<Description>Analyst Ratings, Estimates and Target Price Changes</Description>
<Entity>
<Token>ANACHANGE</Token>
<Description>Analyst Rating Changes</Description>
<Entity>
<Token>ANACUT</Token>
<Description>Analyst Downgrades</Description>
<Entity>
<Token>ANACUTEVT</Token>
<Description>Analyst Ratings Cut Events, Announcements</Description>
</Entity>
</Entity>
</Entity>
</Entity>
<Entity>
<Token>IP</Token>
<Description>Intellectual Property</Description>
<Entity>
<Token>COPYRIGHT</Token>
<Description>Copyrights</Description>
</Entity>
</Entity>
</Entity>
</Entity>
<Entity>
<Token>DRGPATENT</Token>
<Description>Drug Patents</Description>
</Entity>
</Entity>
</Entity>
</CodeList>
modified on Thursday, July 21, 2011 5:25 AM
|
|
|
|
|
Remember when I told you to use int level = book.Select("ancestor::Entity").Count to get the level of a node?
What ancestor::Entity does is returning the list of all the ancestor Entity nodes, you just have to avoid using Count.
If you need the token value, you just have to subsequently select Token, like this: ancestor::Entity/Token .
To understand what you can do with XPath, I strongly suggest you to read here.
|
|
|
|
|
I tried as below
"../Descritpion" gives immediate parent description; "../../Description" gives grandparent's description. and so on..
for (int i = 0; i < level; i++)
{
temp+="../";
parent += book.SelectSingleNode(temp + "Description").Value;
}
I tried book.Select("ancestor::Entity"), as you suggested.
both are working fine. I think first one is not a good programming practice.
Thank you for giving me the link.
|
|
|
|
|
That looks familiar.
|
|
|
|
|
Hello,
I already figured out how to load another assembly from my C# application, and extract the resources embedded to that assembly. My problem is that I'd like to filter the resources by type, i.e. I want to get only text resources, but not icons and other stuff.
The code I use at the moment looks like this:
Assembly target = Assembly.LoadFile(filename);
string[] list = target.GetManifestResourceNames();
foreach (var listentry in list)
{
Stream resourceStream = target.GetManifestResourceStream(listentry);
var rr = new ResourceReader(resourceStream);
IDictionaryEnumerator dict = rr.GetEnumerator();
int ctr = 0;
while (dict.MoveNext())
{
ctr++;
string entry = dict.Value;
}
rr.Close();
}
How can I determine which kind of resource entry I currently get, i.e. if it's an icon, a text resource, or something else?
|
|
|
|
|
Hi,
I am designing simple application using C#. I want to know that, How may I use following oracle query into MS-Access?
Oracle Query is:
string strQuery = "SELECT * FROM ITEMS WHERE NVL(ITEMTYPE,'Z')='P' ";
Thank you
(Riaz)
|
|
|
|
|
Replace NVL to ISNULL. This should work.
Be an Eagle, Sky is Yours.
|
|
|
|
|
Also get rid of the NVL/ISNULL as it is not required in the query - all you are looking for is if ITEMTYPE is equal to 'p' and null is not equal to 'p'.
string strQuery = "SELECT * FROM ITEMS WHERE ITEMTYPE = 'P' ";
This just means that you are not carrying out an unnecessary calculation.
Continuous effort - not strength or intelligence - is the key to unlocking our potential.(Winston Churchill)
|
|
|
|