|
how can i disable the form's movement and response to a mouse click ?
Jesse M
The Code Project Is Your Friend...
|
|
|
|
|
|
I ask a question about PropertyGrid control in C#.
How can I add new PropertyTab into PropertyGrid control?
I write a class inherited from System.Windows.Form.Design.PropertyTab, but it cannot work, I donnt know what is the problem? When I start the Form, the PropertyGrid control can show properly, but there is no new PropertyTab added in. Who knows the answer?
thanks in advance.
Tony L
email: z2629@263.net
I like C#.
|
|
|
|
|
nobody knows the answer?
I like C#.
|
|
|
|
|
This may be a bit long, but I will try to explain it clearly, so please read on.
I'm writing a web-based file management application (in ASP.NET/C#) that requires keeping track of a hierarchy of the names of folders and their files and subfolders (which may include their own files and subfolders). I need to store this whole organizational structure in memory at all times for quick access and modification. This structure will frequently need to be saved to a single file in some format (text, binary or xml) for storage after the application ends.
At first, I thought of using ArrayLists (one for folders and one for files). Each would be written as a single object into a binary file for storage. But I realize that it would be rather hard to manage nested folders using an ArrayList.
My next attempt is to keep track of the folders using a tree stucture. For instance, the 1st level child nodes will be the 1st level folders, and their children nodes can represent their subfolders, and so on. I need to be using a general tree, not a binary tree because a folder cna have more than 2 subfolders. However, I cannot find a Tree class in .NET anywhere. (There's not even a BinaryTree class).
But I did notice that an XML document resembles a general tree structure, which is what I need. My question is that is it possible and efficient for me to store a whole folder hierarchy in XML format?
I've never worked with XML documents before, but basically, I want to know if it possible for me to keep track of nested folders like this: (my syntax may be far from correct)
<folder name="Main Folder" folderCount="2" fileCount="1">
<folder name="Subfolder 1" folderCount="1" fileCount="0">
<folder name="Subfolder 1a" folderCount="0" fileCount="0">
</folder>
</folder>
<folder name="Subfolder 2" folderCount="0" fileCount="0">
</folder>
<file name="File 1">
</file>
</folder>
And remember, I need to be able to keep on adding as many levels of nested folders as I want. Am I able to do this with an XML structure? Also, can I dynamically add, remove or modify any folder?
MSDN says that ".NET XMLDocument class implements the W3C Document Object Model (DOM) Level 1 Core and the Core DOM Level 2. The DOM is an in-memory (cache) tree representation of an XML document and enables the navigation and editing of this document"
If I understand this correctly, it means that this "XML Document" is still an object stored in memory which will allow quick access. I can then write this object to an XML or binary file at any time.
.NET also has an easy way to load the data from the XMLDocument object into a DataSet. This can be very convenient for me because I can map this DataSet to a DataView and then display it on the screen using a DataGrid or DataList. That would be perfect.
OK. So would you suggest the XML method? Or should I just stop dreaming and find a way to manage nested folder using ArrayLists and DataTables? Please let me know. Thanks.
|
|
|
|
|
<Folder name="Main">
<file>Filename</file>
<file>Filename2</file>
<Folder name="SubFolderOne">
<file>Filename1</file>
<file>Filename2</file>
<file>Filename3</file>
</Folder>
</Folder>
There are XML commands to navigate up and down child nodes.
Not sure how you plan to bind hierarchical data to a DataGrid or DataList. I would imagine you are only referring to a sinlge level at a time.
The collections are based on "object". This can be anything. You can have a collections of collections this building your hierarchical data. An SortedList of SortedLists or ArrayList of ArrayList might work for you. This would mean that each Node was a new Collection.
There is an example of something along that lines at:
http://www.dotnetjunkies.com/tutorials.aspx?tutorialid=560[^]
If you need more than just a file name stored you can build your own class for a data item and use it in your collection instead of just a string.
Rocky Moore <><
|
|
|
|
|
I'm making web based application for file/folder management, and I need to keep a hierarchical structure of folders in memory all the time. Is there some kind of class that supports this "tree-like" organization, or do I have make my own implementation.
For instance, there's no Tree collection class? I do see a BinarySeach() method for the ArrayList class, but I dont see any BinaryTree class.
Anyone have any suggestions for how to keep track of a list of folders and their subfolders. The hierarchy must be dynamic and support adding, modifying, removing folder items at runtime. I really cant use a Binary tree structure because a folder can have many subfolders, not just 2 max.
Thanks.
|
|
|
|
|
To do this, you need to create 2 classes:
TreeItem - this hosts your private and public properties such as Path, as well as a TreeItemCollection
TreeItemCollection - inheriting this from CollectionBase will give you the easiest coding path. In this class you will need to implement standard collection methods such as Add, Insert, Remove, IndexOf etc.
|
|
|
|
|
Any ideas how I can display a listbox outside the confinds of a form without placing it on it's own form?
Thanks
Steve Graham
|
|
|
|
|
I don't think taht you can.
Just create a new form, tuen off the border and caption, then set the listbox to the same size as the form.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
|
|
|
|
|
Are there any samples how to use IrDAClient ?
The MSDN doc is very bad for this class (no samples)!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
How can I convert the Graphics object back to a bitmap? I see alot of stuff for one way conversion, but no way to send it back.
Graphics n = Graphics.FromImage(Image.FromHbitmap(tempBitmap.GetHbitmap()));<br />
n.DrawLine(new Pen(new SolidBrush(Color.Beige)),StartPoint,EndPoint);
|
|
|
|
|
I think I'm going to feel a little stupid if the I am correct. But does the above code actually draw on the image.
|
|
|
|
|
|
I wanna ask the same question badly.
if you do:
Graphics n = Graphics.FromImage(tempBitmap);<br />
n.DrawLine(pen,StartPoint,EndPoint);
this will change the tempBitmap;
However,
if you do:
Graphics n = Graphics.FromImage(tempBitmap);<br />
Graphics h=pictureBox.creategraphics();<br />
h.DrawLine(pen,StartPoint,EndPoint);
n=h;
this doesn't seem change tempBitmap.
May some one explain this?
in one word, how do I save everything in the current pictureBox[something are drawn by graphics] into a bmp?
|
|
|
|
|
Think of the Graphics object as being a paint brush, and a Bitmap as being a canvas.
In your 2nd code example, you created a paint brush called "n" but did absolutely nothing with it. You then created a paint brush called "h" but incorrectly set it's canvas to be a PictureBox object - keeping with the anologies, the PictureBox object would be the frame, the actual canvas would be PictureBox.Image.
The basic fix for your code would be:
Graphics n = Graphics.FromImage(tempBitmap);<br />
n.DrawLine(pen,StartPoint,EndPoint);<br />
pictureBox.Image = tempBitmap;
Hope this helps..
|
|
|
|
|
I Get the Following error inside the "Windows form
designer generated code" section for the imagelist that
I've set up for a treeview:
An unhandled exception of
type 'System.Resources.MissingManifestResourceException'
occurred in mscorlib.dll
Additional information: Could not find any resources
appropriate for the specified culture (or the neutral
culture) in the given assembly. Make
sure "ServerComboBoxForm.resources" was correctly
embedded or linked into assembly "ServerComboBox_Test".
baseName: ServerComboBoxForm locationInfo:
NetworkManagement.Demo.ServerComboBoxForm resource file
name: ServerComboBoxForm.resources assembly:
ServerComboBox_Test, Version=1.0.1140.19047,
Culture=neutral, PublicKeyToken=null
Error occurs on this line of the InitializeComponent method:
this.imageList1.ImageStream =
((System.Windows.Forms.ImageListStreamer)
(resources.GetObject("imageList1.ImageStream")));
Can anyone tell me what the problem might be?
thanks.
.
|
|
|
|
|
If you're using a manifest file to make Visual Studio .NET display the XP visual styles, you'll need to create a manifest file for your application too. I got this non-sense error message some days ago, and learned that if you use a manifest file in VS.NET, then build a project, you'll need a manifest file to run the application...
Hope it helps.
John
|
|
|
|
|
John,
thank for the reply... not sure if I'm using a manifest file or not, how do I tell..??? I can add image lists to similar projects without a problem... I find it strange that the error occurs in Windows generated code...
How do I go about creating a manifest file?
|
|
|
|
|
I have had this same problem with VS.NET many, many times - for me it happens when I add my own class *before* a VS.Net generated class; e.g. You derive from the TreeView, but add your own TreeViewItem class in the same code page before the TreeView code. The workaround is to keep the VS.Net class as the first class. Don't know if this is the same problem you're having, but the symptoms are certainly the same.
|
|
|
|
|
Furty,
thanks for the reply... this doesn't seem to be the case for me... the "code page" as you call it, contains only the form class definition, and everything is generated by Windows... the subclased treeview class lives in a different sourcefile, and is only referred to when I instantiate a new treeview item in the form class...
any more suggestions are welcome
|
|
|
|
|
ever figure this one out? im getting the same issue with an imagelist for a toolbar.. dont the problem until i add an image to the imagelist.. exact same error..
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
Look at the reply from "furty" above, this was my problem... I had declared something before the windows generated class, and the problem went away when I moved it further down in the source file...
hope this helps...
|
|
|
|
|
i ended up just making another form and using it.. as for saying you 'had declared something before..' do you mean where you declare your variables at the top of the class (where it generates all the textbox variables, etc.) or do you mean in the initializecomponent() section?
thanks! hopefully i wont run into this problem again..
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
yes, I had added some declarations between the namespace declaration and the windows-generated form class declaration... once I moved those out, the problem went away...
|
|
|
|