C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
7,514 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Dear All, I am learning "ObjectListView" by working with the examples (http://objectlistview.sourceforge.net/cs/blog4.html#blog-rearrangingtreelistview
). However the following error is shown.
The type or namespace name 'ModelWithChildren' could not be found
Could anybody tell me how to solve it?
TIA
The source code is as follows.
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TreeListViewDragDrop
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
// Configure the first tree
treeListView1.CanExpandGetter = delegate (object x) { return true; };
treeListView1.ChildrenGetter = delegate (object x) { return ((ModelWithChildren)x).Children; };
// Configure the second tree
treeListView2.CanExpandGetter = delegate (object x) { return true; };
treeListView2.ChildrenGetter = delegate (object x) { return ((ModelWithChildren)x).Children; };
treeListView1.Roots = ModelWithChildren.CreateModels(null, new ArrayList { 0, 1, 2, 3, 4, 5 });
treeListView2.Roots = ModelWithChildren.CreateModels(null, new ArrayList { "A", "B ", "C", "D", "E" });
}
}
}
No, a using statement for the library which contains
ObjectListView
. Or you can precedeModelWithChildren
with the namespace to whereObjectListView
resides.Since I have not downloaded the library here is an example. I have a class called Customer in a project named DataLibrary then in my form project I reference DataLibrary. To access Customer class I use
Then to create a Customer
Option 2
No using statement
Or if Customer existed in a sub namespace DataLibrary.Classes I would write DataLibrary.Classes.Customer customer - new Customer();
Hi Karen. I have searched the "namespace" for "using" for several days without success. Could you tell me the name of the "namespace" or how to search?
Your namespace in your project is
TreeListViewDragDrop
, all theusing
statements above e.g.using System
,System
is a namespace. What you need to do is find the namespace that ModelWithChildren is under and add a using statement like using System;Also, in regards to the red squiggles, you might try hovering over the squiggles and see if there is a recommendation. I don't know as I use a extension that automatically adds missing references/using statement.
Hi Karen. Is it possible telling me how to search?
Hi @BenTam ,
In the link you provided, it is mentioned in the Dumb models section of the article that all of ObjectListView’s controls revolve around model objects. So, to make a working TreeListView, we need a model for it to display:
So whether the ModelWithChildren class is added to your project?
And the final source code link is provided at the end of the article.
Best Regards,
Daniel Zhang
Hi Daniel. Thanks for your reply,
The last line of the article is "You can download final source code from here." However when I click on the link it shows
"The "/objectlistview/Tree..eListViewDragDrop.7z" file could not be found or is not available. Please select another file."
May I know how to get the source.
Hi @BenTam ,
Since the source code is not available, I suggest you click the discussion button on the right side of the article and ask for help on the discussion page.
Best Regards,
Daniel Zhang
Thanks for your reply. I'll posting on the site.
Sign in to comment
1 answer
Sort by: Most helpful
If this is for ObjectListView then you need to add a reference to your project followed by adding a using statement to form1.
Hi Karen. Thanks for your reply. Very often when I download an example, I need to add some "using XXXXX". My question is how to search XXXXX?
Sign in to comment
Activity