|
Could you tell me one thing where this SQL Server 2005 will be located? Correct me If I am wrong but can you use( or deploy) SQL Server 2005 on Win Mobile? I don't think so. Yeah but you can use SQL Server Compact Edition for Windows Mobile.
Be careful, there is no Undo Button(Ctrl+Z) in life.
|
|
|
|
|
Good Day Fellow Coders;
Given this string coming out of a database field (potentially 10's of thousands of records at a time).
I know that only the first sections will be unique.
I don't know how many of the other sections will be there.
strRef = "Section0.Section1.Section2.Section3.Section4.Section5.Section6.Section7.Section8.Section9"; etc...
I want to create a treeView and I want the nodes to have these properties
//what level is this node
level = level;
//create a tag id
idx = idx + 1;
//create a new tree node
Node = new TreeNode(Name);
//name it
Node.Name = Name;
//give it some text
Node.Text = Name;
//create the tag id
Node.Tag = level + idx;
//assign an image depending on level
Node.ImageIndex = 1;
//assign a selected image depending on level
Node.SelectedImageIndex = 1;
I have done this with spaghetti code about 822 lines but it's only about 97% reliable but all the properties get assigned.
I have also done this using recursion it is 100% reliable but I don't know how to assign the different properties during the recursion process.
I have been working on this a few weeks I have read a couple of books recommended by you folks and have learned a whole lot about how to make a folder browser but this is not quite the same. But I have not been able to solve this yet.
I'm stuck can anyone get me movin in a right direction again.
TIA
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
give some sample data and an example of how you want the tree veiw to be displayed. Im unsure to your requirements
|
|
|
|
|
Sample data might be something like this
strRef = "North Campus.Physics Building.North Side.Floor5.Room 222.East Side.Book Vault 3.1147.B0.shelf 4";
Tree should look like
North Campus
Physics Building
North Side
Floor5
Room 222
East Side
Book Vault 3
1147
B0
shelf 4
Build 1259
North Side
Floor1
Room 21
West Side
Closet n5
shelf 4
Is this what you requested?
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
ok i think i see what you want now. I will give some code guideline, sorry if its not what you need thou
foreach(DataRow row in DataTable)
{
string[] parts = row["ColumnName"].ToString().Split('.');
TreeNode baseNode = RootNode;
foreach(string s in parts)
{
TreeNode temp = CheckNodeExists(s, baseNode);
if(temp == null)
temp = baseNode.AddNode("ID", "Name", "Image")
baseNode = temp;
}
}
public TreeNode CheckNodeExists(string nodeText, TreeNodeCollection nodes)
{
if(nodes == null || nodes.Count == 0)
return null;
foreach(TreeNode node in nodes)
if(node.Text == nodeText)
return node;
return null;
}
Please let me know if this is not what you want and i will try to offer more help
|
|
|
|
|
maybe this would help...this is the recursion I am currently using.
fullRef is the name of the variable from the database
Now in here I'm not sure where I can add properties to the Nodes.
string[] strArr = fullRef.Split('.');
List<string> NODES = new List<string>(); //Save nodes
foreach (string str in strArr)
NODES.Add(str);
InsertNodes(treeView1.Nodes, NODES);
}
treeView1.CollapseAll();
treeView1.SelectedNode = treeView1.SelectedNode = treeView1.Nodes[0].Nodes[0].Nodes[0];
treeView1.EndUpdate();
this.Cursor = Cursors.Default;
}
}
TreeNode AddNode(TreeNodeCollection Parent, string text)
{
TreeNode temporaryNode;
foreach (TreeNode node in Parent)
{
if (node.Text == text)
{
return node;
}
}
return Parent.Add(text);
}
void InsertNodes(TreeNodeCollection treeviewNodes, List<string> _nodes)
{
if (_nodes.Count == 0)
return; //Recursive exit
TreeNode TempNode = AddNode(treeviewNodes, _nodes[0]);
_nodes.RemoveAt(0);
InsertNodes(TempNode.Nodes, _nodes); //Recursive calling
}
TIA
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
memory allocated on heap in method referenced by local variable declared within the method - will memory be reclaimed/collected automatically by CLR?
Thanks
dev
|
|
|
|
|
Yes, when all references are gone (at the next garbage collection cycle). In your case, when the local variable goes out of scope.
Regards,
Rob Philpott.
|
|
|
|
|
devvvy wrote: in method referenced by local variable declared within the method
Huh, like this?
void Test()
{
var V = Test;
}
?
I are troll
|
|
|
|
|
no... more like this
<br />
public class Something<br />
{<br />
...<br />
public void SomeMethod()<br />
{<br />
SomeObj o = new SomeObj();<br />
o.DoSomeWork();<br />
return;<br />
}<br />
...<br />
}<br />
dev
|
|
|
|
|
Yup
I are troll
|
|
|
|
|
devvvy wrote: If I don't have this line "o" would stil lbe garbage collected on method exit right?
Or even earlier, if possible.
|
|
|
|
|
The object is up for garbage collection as soon as it's not used any more.
Actually, setting the reference to null is totally pointless in this scenario. The garbage collector knows that the object is not used any more after the call to DoSomeWork, so the object may even be collected before you set the reference to null.
It's not the scope of the variable that decides garbage collection, only usage. The garbage collector only cares about where the objects are used, it's just the compiler that cares about the scope of variables.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi,
I disagree with what all others said on the subject.
Here are some facts:
1. if o.DoSomeWork(); stores a reference to o somewhere (using this inside the DoSomeWork method), say in a static List< SomeObj>, then o will not be collectable as long as the list lives, no mather how often you do o=null; or return;
Assuming DoSomeWork does not cause a reference to be stored:
2. return; does not cause the gc to run.
3. when SomeMethod() returns, o is collectable , which means it could/should be collected by the gc if there were a reason for the gc to run. Normally the only reason for gc to run is an explicit need for memory, as in SomeThingElse els=new SomeThingElse(); anywhere in your process. Without a need for memory, no gc run, no collection at that point.
4. if o were the only reference to your SomeObj, then setting it null, removes the last reference to the object, and hence makes it collectable (again, not collected). Having the method return also removes the last reference, hence nulling a reference does not make sense just before a return. It does make sense when a lengthy operation sits in between o=null; and return; though.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:56 AM
|
|
|
|
|
Luc Pattyn wrote: if o were the only reference to your SomeObj, then setting it null, removes the last reference to the object, and hence makes it collectable
Well, My understanding was setting null will not make any difference for garbage collection. I believe GC is brilliant enough to know when the object is no more used.
I agree to all other what you said
|
|
|
|
|
N a v a n e e t h wrote: setting null will not make any difference for garbage collection
yes it does. The GC looks for references "everywhere" while performing its "mark pass" (assuming a simple "mark and sweep" type GC). Every time you remove a last reference somewhere (e.g. by writing null over it), you make the referred object collectible (i.e. it no longer gets marked as "in use", so the sweep pass will destroy it). The GC is *not* analyzing your code to predict whether an object will still be used in the future, it only determines "reachability", i.e. the theoretical possibility to access it again, based on the data structures only.
In the meantime I have developed a little app that demonstrates exactly how the GC works. When I find
the time, I will write a short article on the subject.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Luc Pattyn wrote: The GC is *not* analyzing your code to predict whether an object will still be used in the future, it only determines "reachability", i.e. the theoretical possibility to access it again
So do you usually set null when you are done with the object in your projects? I have seen very less projects doing this. You may interest in this[^]. In that post, author says,
Setting things to null
So, should you set your reference types to null when you're done with them? Of course not. Once a variable falls out of scope, it's popped of the stack and the reference is removed. If you can't wait for the scope to exit, you likely need to refactor your code.
I have seen similar explantion in CLR via C#[^] book by Jeffrey Richter.
Luc Pattyn wrote: In the meantime I have developed a little app that demonstrates exactly how the GC works. When I find
the time, I will write a short article on the subject.
WOW! that is going to be true fun. When we can expect that? Looking forward to read the article.
|
|
|
|
|
Hi,
N a v a n e e t h wrote: So do you usually set null ...
No, I don't because my code typically does not satisfy the last condition in my earlier point 4.[^]
But I would when circumstances were such that it would make sense.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
how do i scan an image column wise in c# . i need help with the code . i wanted to read the next pixel of the same column .please help im a beginner in image processing
Thanks in advance
|
|
|
|
|
well if your image is a bitmap you can create a 2D array of pixels then loop through columns and rows
actually just use:
Bitmap b = new Bitmap(filepath);
for(int i = 0; i < b.Width; i++)
{
for(int j = 0; j < b.Height; j++)
{
Color c = b.GetPixel(i, j);
}
}
|
|
|
|
|
do u mean i can use getpixel and setpixel method to solve this....i was intending to use unsafe code so that it could be faster....
|
|
|
|
|
what do you want to do with the pixels?
|
|
|
|
|
i am trying to segment characters from a string of characters in a license plate image....i want to scan my image column wise so that i can extract every character ....so i need to find how many black pixels are present in a column....
|
|
|
|
|
Good luck lol :P
You do have to go through the pixels though, so I would stay with my GetPixel() suggestion. I dont know of another alternative to getting the pixels sorry (unless you read the file yourself, but then you would have to store pixels as an array, and loop through them yourself)
Just out of interest - what algorithms will you be using to detect the letters?
|
|
|
|
|
There's some articles on CP that deal with OCR. Would still be a challenge, I guess
I are troll
|
|
|
|