|
It doesn't seem like it would be difficult to reapply the expanded or collapsed state of the nodes during the recursion -- I'm actually surprised its necessary since expanded/collapsed is a property of the individual nodes and all we are doing is reordering the references -- perhaps the state gets reset when the nodes get re-added to the tree control (I haven't tried it so can't answer with certainty).
Once you've sorted the tree once you may want to handle inserted nodes in a slightly different way -- that is, the code which creates the node would also determine where the node should be placed. Its more work but might be preferable to resorting the branch every time a node is added. Again without actually trying it I'm not sure if this is difficult or not.
When sorting a large tree I would try to make use of SuspendLayout() and ResumeLayout() so that screenupdating is a non-issue. I would guess that once you have done this your tree would need to get very large before sorting gets slow.
For really large trees, recursion could be an issue -- although when you think about it, its really only the depth of the tree that matters. If recursion is no longer viable to get to the maximum depth in your tree chances are that your users probably hate you (who wants to drill down through a hundred nodes to find something?). Same comment stands for the number of nodes in a tree -- you can sort thousands of items in no time so the tree would have to be huge before it got to be a problem. At that point you're probably into virtual trees which you populate as the user is expanding them.
One last comment. I've done treeview sorting the old fashioned way (in C++ with callback functions and TV_ITEM structures). It was pretty painful. Given the choice I'll take the .Net approach any day.
|
|
|
|
|
OKz,
I will try the way which u have told me.
Thx n regards
Umair
|
|
|
|
|
Here's the deal. I got an image of a building plan loaded in my Picturebox.
Now I have to mark the rooms on it... and to a room I need to assign certain parameters.
2 problems:
1. I need to use a kind of magnetic lasso tool or pen tool (photoshop) to mark the rooms
2. how do I draw "object/controls" on top of an image?
Thanx in advance
"Paranoia is reality on a tighter edge"
|
|
|
|
|
From GDI+ you can use Graphics.Draw//anything() .
but at this you must make that image the background image.
|
|
|
|
|
I'm currently experementing with Graphicpath... and seems to work out great.
|
|
|
|
|
Hi folks,
Do you guys know how to check if a folder is shared and what users have permission on it?
Thanks.
|
|
|
|
|
I have to use SQL queries and generate a dataset and then attach it to a crystal report. All this to be done through coding and not using any experts
i wrote the following ...but it showed a blank form . Please Help
string st="server=localhost;user id=sa;password=ims;database=ProActiveTrainingDB";
SqlConnection s=new SqlConnection(st);
SqlDataAdapter sd=new SqlDataAdapter("Select * from JobTitleMaster",s);
DataSet dset=new DataSet();
try
{
sd.Fill(dset, "JobTitleMaster");
bRpt.SetDataSource(dset);
crystalReportViewer1.ReportSource = bRpt;
crystalReportViewer1.RefreshReport();
}
catch(Exception ex)
{
MessageBox.Show("Report causing Problems");
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Sukanya
|
|
|
|
|
I wrote a control. It is a timer with 1 button (Start/Stop) and 3 readonly textboxes to show the start time, stop time, running time. It also has a public method Start() which is also used in the ClickEvent of the button to start the timer. While the timer is running, the textbox that shows the running time is updated every second.
Here's the weird part. When Timer.Start() is called in another thread, the textboxes that should show the details are not updated on a certain interval. The reason why I put the call to Timer.Start() in another thread is that it's called by a remote host via sockets. The remote host sends its hostname which corresponds to a certain field in a set of MyTimer controls.
The update is in the Tick event of a Timer control within my control. I tried putting messageBox routines and I did find out, they are not executed. The Tick event does not fire!!! The timer works fine when using the start button to start it. Is this due to the fact that the event occurs in the _main_ thread?
Please enlighten me about this weird behaviour.
|
|
|
|
|
From your description, it looks like you are System.Windows.Forms Timer. That Timer's Tick event is on the UI thread, so you should be fine there. I'm wondering about calling Start from another thread though, maybe you should use Invoke/BeginInvoke and call Start on the UI thread? According to MSDN documentation, no UI method/property on any control may be called from another thread, except for InvokeRequired, Invoke() and BeginInvoke().
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi Senthil. I use the asynchronous Begin/EndInvoke and it works!
|
|
|
|
|
Following is my code for a simple thread
public static void U()
{
IPEndPoint ipe = new IPEndPoint(IPAddress.Any,1238);
EndPoint LocalEP = (EndPoint) ipe;
//Socket ServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
//ServerSocket.Bind(LocalEP);
Console.WriteLine("I am codeproject user");
while(true)
{
Thread.Sleep(10);
Console.Write(". ");
}
}
It is surprised that when I use
//Socket ServerSocket = new Socket(AddressFamily.InterNetwork,SocketType.Dgram, ProtocolType.Udp);
the thread is not working .
|
|
|
|
|
Funny... I don't see any code in your post that creates a new thread, so yes, it doesn't work.
What are you trying to accomplish? I assume it's a multithreaded server application that accept client connections and launches a new thread for each client. But in your case, you never started a listener, so I fail to see how your even going to accept connections...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
The following error occurs when trying to drag a custom control's icon onto a form:
Microsoft Development Environment
An exception occurred while trying to create an instance of MyCustomControl.MyCustomControl. The exception was "File not found. File name is: c\documents and settings\athorne\application data\microsoft\visualstudio\MyCustomControl\MyFile.htm".
OK
The MyFile.htm is a file that MyCustomControl uses. I can add MyCustomControl manually, just not via the toolbox.
Background: This error message first appeared while I was demo-ing my work to my co-workers I had recently tried to change MyCustomControl's Toolbox icon. Even though I followed all of the steps for changing the icon, the icon was not changed in the Toolbox, I did not see the icon (MyCustomControl.bmp) in the Toolbox and I did not see the icon's name in the Manifest. Since the icon was not changed, I removed MyCustomControl.bmp from the project and from the project's folder. In some of my research in trying to decipher the above error, I found that the application data\microsoft\visualstudio folder holds toolbar information, along with other information, so I am thinking that perhaps my experimentation in changing the Toolbox icon could have caused the problem...
Any help is very much appreciated!
Anne
|
|
|
|
|
|
Thank you so much for responding to my post. The code for my control does not include a hard coded path Here it is:
using System;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Diagnostics;<br />
using System.Drawing;<br />
using System.IO;<br />
using System.Reflection;<br />
using System.Windows.Forms;<br />
using Syncfusion.Windows.Forms.HTMLUI;<br />
<br />
namespace MyCustomControl<br />
{<br />
<br />
public class MyCustomControl: HTMLUIControl<br />
{<br />
static string filePath = null;<br />
<br />
public MyCustomControl()<br />
{<br />
this.AutoScroll = true;<br />
this.ShowTitle = false;<br />
LoadFromFile("MyFile.htm");<br />
}<br />
<br />
<br />
private void LoadFromFile(string fileName)<br />
{<br />
string filePath = GetFilesLocation() + fileName;<br />
this.LoadHTML(filePath);<br />
}<br />
<br />
static string GetFilesLocation()<br />
{<br />
if(filePath != null)<br />
return filePath;<br />
<br />
string path;<br />
path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );<br />
int slashPos = path.LastIndexOf("\\",path.Length);<br />
slashPos = path.LastIndexOf("\\",slashPos-1);<br />
slashPos = path.LastIndexOf("\\",slashPos-1);<br />
if(slashPos > 0)<br />
path = path.Substring(0,slashPos);<br />
path = path.Replace("file:\\", "");<br />
filePath = path + "\\MyCustomControl\\";<br />
return filePath;<br />
}<br />
<br />
public override string Text<br />
{<br />
set<br />
{<br />
return;<br />
}<br />
}<br />
}<br />
}
Thanks for any and all help on this matter,
Anne
|
|
|
|
|
One of the developers in my group figured out what the problem was.
When the control is dragged onto the form, the constructor is initiated. The path information is confused at that point, hence it uses a toolbox type path...
Part of the solution is to create the html file on the fly from a database.
Thanks!
Anne
|
|
|
|
|
Hi folks,
I want to create a client application that will call some methods from webservices. It's simple if we know the server name but in this application, I want to pass the name of webservice server flexible.
Could you guys give me a hint?
Thanks.
|
|
|
|
|
How about putting the name of server in App.config and reading it from there at runtime? You'd have to make some changes to the proxy created by VS .NET though, IIRC, it hardcodes the URL of the server in the Reference.cs file it generates when you add a web reference.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
hi,
i Face 2 problems :
1- when i try to connect through my e-mail client it permits some mails to connect either don't i donno why ?
2-
string type = mailBoxNode.SelectSingleNode"descendant::hm:special",context).InnerText; <br />
string nameUrl = mailBoxNode.SelectSingleNode"descendant::D:href",context).InnerText;<br />
int visibleCount = Int32.Parse(mailBoxNode.SelectSingleNode("descendant::D:visiblecount",context).InnerText);<br />
int unreadCount = Int32.Parse(mailBoxNode.SelectSingleNode("descendant::hm:unreadcount",context).InnerText);
i use this code to get the data about my folders but i need the data of the mails it self i donno what to write for the xpath
can any help me please
thanks in advance
|
|
|
|
|
What I'm trying to do is create selftest application which has multi choice questions, drag & drop, point and shot etc. Im using windows forms. I was planning on having each questions data in an rtf file (because it contains both text and graphics) then load it into a richtextbox. Only problem is that it's going to take a lot of code to do it.
I understand the use of arrays etc for text only, but how can i best structure it if there is both text and images?? How do you combine the two?
If somone could please point me in the right direction
|
|
|
|
|
I'm not sure what you're asking - you want an array of questions, and each question will contain text and a graphic ? Or will the number of texts and graphics vary ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yes exactly, sorry I wasn't clear enough. I want an array of questions that contain both text and 1 or 2 graphics. I can create an array of questions that use text but i can't figure out how to include one or more images. So that when i retrieve the data i can then display the text and image/s on the screen.
|
|
|
|
|
I'd do something like this
struct QuestionImage
{
public Bitmap image;
public Point position;
}
class Question
{
string text;
ArrayList images;
public void AddImage(Bitmap image, Point pos)
{
images.Add(new QuestionImage(image, pos);
There's obviously a lot of code missing, that's just to show my overall approach.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Did anybody run across the problem that I have. I created a service and installed on the remote pc. The service is supposed to start an exe that is located on the LAN server. The started exe is checking a couple of the LAN drives/paths and that's where it fails. For some reason the service started exe has a problem of seeing LAN drives. The other thing is that the exe has "NETWORK SERVICE" User Name under Windows Task Manager vs. logged in user name. Can anybody help (permission???, user name???)? Any help is appreciated!
|
|
|
|
|
Your service doesn't run in the context of the logged in user. You'll have to go into the Services control panel and change the account that it runs under. Create an account that has the appropriate rights to all the resources that the service will need. It's done just like creating an account for a normal user. Change the account details in the Services control panel for your service, then restart it. So long as the account is setup correctly, your application will run using those credentials.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|