By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,695 Members | 1,310 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,695 IT Pros & Developers. It's quick & easy.

TreeView samples

P: n/a
Anybody can shart some working samples of using that control on Windows
form?

Thanks
Nov 15 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
I think MSDN Library should have some. If you are experiencing particular
problems with TreeView, please post them here, or, even better, in the
microsoft.public.dotnet.framework.windowsforms newsgroup.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Mark Goldin" <ma********@comcast.net> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
Anybody can shart some working samples of using that control on Windows
form?

Thanks


Nov 15 '05 #2

P: n/a
No I dont experience any PARTICULAR problem.
I am experiencing PROBLEM to get started in .NET.
Usually samples are very helpful.

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:Ok**************@TK2MSFTNGP09.phx.gbl...
I think MSDN Library should have some. If you are experiencing particular
problems with TreeView, please post them here, or, even better, in the
microsoft.public.dotnet.framework.windowsforms newsgroup.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Mark Goldin" <ma********@comcast.net> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
Anybody can shart some working samples of using that control on Windows
form?

Thanks

Nov 15 '05 #3

P: n/a
I see your point, Mark. Then MSDN examples are a good point to start, as
well as GotDotNet QuickStart tutorials (found at http://www.gotdotnet.com).

You can also look at the .NET 247 portal (http://www.dotnet247.com if I am
not mistaken).

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Mark Goldin" <ma********@comcast.net> wrote in message
news:eS**************@TK2MSFTNGP11.phx.gbl...
No I dont experience any PARTICULAR problem.
I am experiencing PROBLEM to get started in .NET.
Usually samples are very helpful.

"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:Ok**************@TK2MSFTNGP09.phx.gbl...
I think MSDN Library should have some. If you are experiencing particular problems with TreeView, please post them here, or, even better, in the
microsoft.public.dotnet.framework.windowsforms newsgroup.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Mark Goldin" <ma********@comcast.net> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
Anybody can shart some working samples of using that control on Windows form?

Thanks



Nov 15 '05 #4

P: n/a
Thanks for help.
Would it be better idea to use third party component for
TreeView? The component that already has (or almost)
functionality I need?
-----Original Message-----
I see your point, Mark. Then MSDN examples are a good point to start, aswell as GotDotNet QuickStart tutorials (found at http://www.gotdotnet.com).
You can also look at the .NET 247 portal (http://www.dotnet247.com if I amnot mistaken).

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Mark Goldin" <ma********@comcast.net> wrote in message
news:eS**************@TK2MSFTNGP11.phx.gbl...
No I dont experience any PARTICULAR problem.
I am experiencing PROBLEM to get started in .NET.
Usually samples are very helpful.

"Dmitriy Lapshin [C# / .NET MVP]" <x-code@no-spam- please.hotpop.com> wrote
in message
news:Ok**************@TK2MSFTNGP09.phx.gbl...
> I think MSDN Library should have some. If you are experiencingparticular
> problems with TreeView, please post them here, or,
even better, in the > microsoft.public.dotnet.framework.windowsforms newsgroup. >
> --
> Dmitriy Lapshin [C# / .NET MVP]
> X-Unity Test Studio
> http://x-unity.miik.com.ua/teststudio.aspx
> Bring the power of unit testing to VS .NET IDE
>
> "Mark Goldin" <ma********@comcast.net> wrote in message > news:Oj**************@TK2MSFTNGP11.phx.gbl...
> > Anybody can shart some working samples of using
that control onWindows > > form?
> >
> > Thanks
> >
> >
>



.

Nov 15 '05 #5

P: n/a
The following Method fills a TreeView with the DataSet (and its Tables)
Strucure.
You mut call the Method with a reference to your exsisting TreeView
Control, DataSet to use and a String Array with Branch/Node Strings to use.
In my Projects these Strings are Language dependent and must be filled
beforhand.

OnFillTreeViewDataSet(ref TreeViewDataSet, ref dset_MainFrame, ref
sa_TreeViewDataSet);

Hope this helps as a starter.

Mark Johnson, Berlin Germany
mj*****@mj10777.de
private void OnFillTreeViewDataSet(ref TreeView ref_treeView, ref DataSet
dset_MainFrame, ref String[] sa_treeView)
{
string s_DataSet="",s_TableName="", s_FieldName="";
//---------------------------------------------------------------
string s_DataConnections="";
string s_AmountFields= "",s_AmountRows="",s_AmountTables="";
s_DataConnections = sa_treeView[1]; // "Data Connections";
s_AmountFields = sa_treeView[4]; // "Columns";
s_AmountRows = sa_treeView[5]; // "Rows";
if (dset_MainFrame.Tables.Count == 1)
s_AmountTables = sa_treeView[2]; // "Table";
else
s_AmountTables = sa_treeView[3]; // "Tables";
//---------------
// Display a wait cursor while the TreeNodes are being created.
Cursor.Current = Cursors.WaitCursor;
// Suppress repainting the TreeView until all the objects have been
created.
ref_treeView.BeginUpdate();
// Clear the TreeView each time the method is called.
ref_treeView.Nodes.Clear();
// Net.Framework.Compact does not support new TreeNode(s_DataSet,2,1);
// - thus we must do it per hand in 5 Steps instead of 1, but it should
work on both Systems
TreeNode tn_Node=null;
for (int i_DataSet=0;i_DataSet<1;i_DataSet++)
{
tn_Node = new TreeNode(); // Step 1 - only this
is possible the NET Framework.Compact
tn_Node.Text = s_DataConnections; // Step 2 - we really
don't need s_DataSet !
tn_Node.ImageIndex = 0; // Step 3 - Not
Selected - DataConnection.gif
tn_Node.SelectedImageIndex = 0; // Step 4 - Is
Selected - DataConnection.gif
ref_treeView.Nodes.Add(tn_Node);
if (dset_MainFrame.Namespace != sa_treeView[0])
{
s_DataSet = dset_MainFrame.Namespace;
tn_Node = new TreeNode();
tn_Node.Text = s_DataSet;
tn_Node.ImageIndex = 1; // Does this work ? -
DataBase_Closed.gif
tn_Node.SelectedImageIndex = 2; // Does this work ? -
DataBase_Open.gif
ref_treeView.Nodes[i_DataSet].Nodes.Add(tn_Node);
tn_Node = new TreeNode();
tn_Node.Text =
dset_MainFrame.Tables.Count.ToString()+" "+s_AmountTables;
tn_Node.ImageIndex = 8; // - NOTE12.ICO
tn_Node.SelectedImageIndex = 8; // - NOTE12.ICO
ref_treeView.Nodes[i_DataSet].Nodes[i_DataSet].Nodes.Add(tn_Node);
for(int i_Table=0;i_Table<dset_MainFrame.Tables.Count;i_Ta ble++)
{
DataTable dt_Table = dset_MainFrame.Tables[i_Table];
s_TableName = dt_Table.TableName;
tn_Node = new TreeNode();
tn_Node.Text = s_TableName;
tn_Node.ImageIndex = 6; // Does this work ?
tn_Node.SelectedImageIndex = 5; // Does this work ?

ref_treeView.Nodes[i_DataSet].Nodes[i_DataSet].Nodes[i_DataSet].Nodes.Add(tn
_Node);
tn_Node = new TreeNode();
tn_Node.Text = dt_Table.Columns.Count+"
"+s_AmountFields+", "+dt_Table.Rows.Count.ToString()+" "+s_AmountRows;
tn_Node.ImageIndex = 9; // - NOTE12.ICO
tn_Node.SelectedImageIndex = 9; // - NOTE12.ICO

ref_treeView.Nodes[i_DataSet].Nodes[i_DataSet].Nodes[i_DataSet].Nodes[i_Tabl
e].Nodes.Add(tn_Node);
for(int i_Fields=0;i_Fields<dt_Table.Columns.Count;i_Field s++)
{
s_FieldName = dt_Table.Columns[i_Fields].ColumnName; // May
not work > 0
tn_Node = new TreeNode();
tn_Node.Text = s_FieldName;
tn_Node.ImageIndex = 7; // Column.ico
tn_Node.SelectedImageIndex = 7; // Column.ico

ref_treeView.Nodes[i_DataSet].Nodes[i_DataSet].Nodes[i_DataSet].Nodes[i_Tabl
e].Nodes[i_DataSet].Nodes.Add(tn_Node);
tn_Node = new TreeNode();
tn_Node.Text =
dt_Table.Columns[i_Fields].DataType.ToString();
tn_Node.ImageIndex = 10; // - NOTE12.ICO
tn_Node.SelectedImageIndex = 10; // - NOTE12.ICO

ref_treeView.Nodes[i_DataSet].Nodes[i_DataSet].Nodes[i_DataSet].Nodes[i_Tabl
e].Nodes[i_DataSet].Nodes[i_Fields].Nodes.Add(tn_Node);
} // for(int i_Fields=0;i_Fields<dt_Table.Columns.Count;i_Field s++)
} // for(int i_Table=0;i_Table<dset_MainFrame.Tables.Count;i_Ta ble++)
} // if (dset_MainFrame.Namespace != sa_treeView[0])
} // for (int i_DataSet=0;i_DataSet<1;i_DataSet++)
// Open all the nodes
ref_treeView.ExpandAll();
// Begin repainting the TreeView.
ref_treeView.EndUpdate();
if (ref_treeView == TreeViewDataSet)
{ // this is TreeView and DataTable specific !
if (dtable_MainFrame00 != null)
i_MainFrame00SortCol = 0; // Rebuild ListView if Table is filled
} // if (treeViewDataSet == TreeViewDataSet)
// Reset the cursor to the default for all controls.
Cursor.Current = Cursors.Default;
//---------------
} // private void OnFillTreeViewDataSet(ref ref_treeView, ref
dset_MainFrame, ref sa_treeView)
#endregion


"Mark Goldin" <ma********@comcast.net> wrote in message
news:Oj**************@TK2MSFTNGP11.phx.gbl...
Anybody can shart some working samples of using that control on Windows
form?

Thanks

Nov 15 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.