473,699 Members | 2,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Serializing TreeView and DataGridView controls states

Hello All,
First of all thanks in advance to everyone who will try to help me.
I have Form with TreeView control and DataGridView control. Each TreeNode has its own rows and due to I am placing rows to ArrayList and store it in
tag of TreeNode like this:

// dgv - DataGridView visible within whole class

private void treeView1_After Select(object sender, TreeViewEventAr gs e)
{
dgv.Rows.Clear( );
dgv.Columns.Cle ar();
DataGridViewChe ckBoxColumn ins = new DataGridViewChe ckBoxColumn();
ins.Name = "Insert";
ins.HeaderText = "Insert;
ins.Width = 90;

DataGridViewTex tBoxColumn itemName = new DataGridViewTex tBoxColumn();
itemName.Header Text = "Item name";
itemName.Name = "itemName";
itemName.Width = (dgv.Width - ins.Width - 43) / 2;

DataGridViewTex tBoxColumn itemValue = new DataGridViewTex tBoxColumn();
itemValue.Heade rText = "Item Value";
itemValue.Name = "itemValue" ;
itemValue.Width = (dgv.Width - ins.Width - 43) / 2;

DataGridViewCom boBoxColumn mdfLink = new DataGridViewCom boBoxColumn();
mdfLink.Name = "mdfLink";
mdfLink.HeaderT ext = "MDF Link";
mdfLink.Width = (dgv.Width - 80) / 6;
mdfLink.DropDow nWidth = mdfLink.Width * 2;

dgv.Columns.Add Range(new DataGridViewCol umn[] {ins,itemName,i temValue, mdfLink});

if (treeView1.Sele ctedNode.Tag != null)
{
ArrayList al = (ArrayList)tree View1.SelectedN ode.Tag;
foreach (object obj in al)
{
dgv.Rows.Add((D ataGridViewRow) obj);
}
}
else
{
// fill rows manually
// ...
}
}

private void treeView1_Befor eSelect(object sender, TreeViewCancelE ventArgs e)
{
ArrayList al = new ArrayList();
foreach (DataGridViewRo w dgvr in dgv.Rows)
{
al.Add(dgvr);
}
if (al.Count != 0)
{
treeView1.Selec tedNode.Tag = al;
}
}

And I need to store state of TreeView in a file by serialization to future restoring (I know that TreeView doesn't support serialization but TreeNoew
does). But DataGridViewRow is not support serialization.
As matter of fact I tried to store values in string arrays and populate it accordingly.

My question is:
1. Is anybody know better way of serialization of treeview with attached DataGridView?
2. In case of using my method how do I save/restore selected item of ComboBoxCell?

I will appreciate any help.

Best regards,
/Gelios
Feb 24 '06 #1
0 1708

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

42
11538
by: lauren quantrell | last post by:
So many postings on not to use the treeview control, but nothing recently. Is it safe to swim there yet with Access 2000-Access 2003?
3
12167
by: Ian | last post by:
Hi, I've been trying to create a listview and treeview with icons. You would think it's a pretty straight forward task. API documentation states you simply assign an ImageList - that's been populated either using VS.NET (my method) or programatically. I assigned the imagelist to the small icons in the listview. Even VS.NET has been satisfied with what I'm doing as it shows the listitems/treenodes with icons. As soon as I build/run...
3
2645
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event and this causes control B to be created, when this is done the VIEWSTATE is lost for CONTROL B. In the EVENT that causes CONTROL B to be created I have to set
2
2674
by: kevin | last post by:
I would like to remember the state of the nodes after the treeview gets disposed, but not necessarily after the app terminates so I don't need a disk file. I was thinking about using the tag property, but I am already using it, so then I though about making a custom treeiew using inheritance and adding another tag type property? Any clues? kevin
0
415
by: Mark Carew | last post by:
Hi, I'm writing a winform app (as practice) that has as one of its features a button that reads an xml file to a datagridview. No matter what I do I get two columns instead of one. The "first column", I retrieve and place the text "Holy Cat" in its header text. This column contains no data from the xml file. The second column contains the correct data from the xml file.
4
4745
by: colin | last post by:
Hi, I wish to display and edit 3 collections of different object types, each object type also has a collection of the other 2 types, such that if one object contains another then the reverse is always true, a many to many relationship. the objects are 3d objects making up a wire mesh model, points,wire,surfaces. im not sure wich is the best way to go,
0
7163
by: Dennis Francek | last post by:
Hello I have populated a treeview from my dataset and by clicking in the treeview i want to get the corresponding table shown in a datagridview. Ive managed this by looking at each DataRow and child rows and added the nodes with a columnname from each datarow. At the same time i have put in a tag at each treenode with a filter string and the current table im looking at as a string to use for later so i can create a datatable and set a filter...
1
4399
by: =?Utf-8?B?TG9yZW4=?= | last post by:
I’m having a couple of problems using the TreeView control on a windows form. I feel as if I’m missing something very obvious, but I not seeing it! Any suggestions would be appreciated. 1. I’d like to change the background color of the selected treeview node. To do this it looks as if I need to change the treeview’s SelectedNodeStyle property. MSDN states that “this property is read-only; however, you can set the properties...
0
1969
by: AKIAKI | last post by:
Hello. I wish TreeView & DataGridView were synchronized. (Same row is Selected and Selected Row is equal high ) I set DataGridView & TreeView on Split Container. When TreeView does not have Horizontal scroll and DataGridView has Horizontal scroll, The displayed number of items is different. please tell me Method of displaying horizontal scroll in Treeview.
0
8617
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8884
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7751
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2347
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.