473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to fill listview in a different class and file?

In Form1.cs I have defined the "InstituteAdministrator"
class which contains ListView "listViewAddress". In a second
file (FormTreeView.cs) I have the class FormTreeView with
the method "dataTreeView1_AfterSelect". When the user
selects a node in the treeview, then listViewAddress should
be filled and displayed with the corresponding addresses.

As long as I keep the whole thing in one file, it works
fine, but not with two files and two classes.

I want to use dotnetmagic.com's libraries, which come with
this two-files example for docking.

First I created a method within the InstituteAdministrator
class which establishes the database connection and fills
the listview. Within FormTreeView class I made a reference
to the Institute Administrator class and called the filling
method I defined, passing "e.Node.Tag.ToString()" as
parameter to the method.

The program seemed to work, however the data is not
displaying in the listview. Since then I'm trying out (try
and error...). So far I did not find sufficient information
in books or online examples to help me to understand what is
going on. (needless to say that I'm a newbie)

Which are the steps to make this work? Any hints, anyone?

Link to screenshots and source-files:
http://www.osswald.com/vstudio/

Direct link to source files (flash-paper prints):
http://www.osswald.com/vstudio/images/form1.cs.swf
http://www.osswald.com/vstudio/image...reeView.cs.swf

Thanks, Oliver

Nov 17 '05 #1
2 2933
hi

I assume you have both forms visible, if so you need to pass a reference of
the listviewform to the FormTreeView, you can do that whne you create the
latter. in the first form create a public method that will receive the ID
from thre selected tree, then the method will retrieve the data and populate
the listview

In the worst case that the TreeView's form is not create by the first form
you could keep a reference to the currently displayed form in a static
property.
hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"Ole Baba" <ol****@gmx.net> wrote in message
news:db**********@news.hispeed.ch...
In Form1.cs I have defined the "InstituteAdministrator" class which
contains ListView "listViewAddress". In a second file (FormTreeView.cs) I
have the class FormTreeView with the method "dataTreeView1_AfterSelect".
When the user selects a node in the treeview, then listViewAddress should
be filled and displayed with the corresponding addresses.

As long as I keep the whole thing in one file, it works fine, but not with
two files and two classes.

I want to use dotnetmagic.com's libraries, which come with this two-files
example for docking.

First I created a method within the InstituteAdministrator class which
establishes the database connection and fills the listview. Within
FormTreeView class I made a reference to the Institute Administrator class
and called the filling method I defined, passing "e.Node.Tag.ToString()"
as parameter to the method.

The program seemed to work, however the data is not displaying in the
listview. Since then I'm trying out (try and error...). So far I did not
find sufficient information in books or online examples to help me to
understand what is going on. (needless to say that I'm a newbie)

Which are the steps to make this work? Any hints, anyone?

Link to screenshots and source-files:
http://www.osswald.com/vstudio/

Direct link to source files (flash-paper prints):
http://www.osswald.com/vstudio/images/form1.cs.swf
http://www.osswald.com/vstudio/image...reeView.cs.swf

Thanks, Oliver

Nov 17 '05 #2
"Ignacio Machin \( .NET/ C# MVP \)" wrote:
I assume you have both forms visible,
if so you need to pass a reference of
the listviewform to the FormTreeView,
you can do that whne you create the
latter. in the first form create a
public method that will receive the ID
from thre selected tree, then the method
will retrieve the data and populate
the listview


Great! It worked! It took me some moments to figure out what "pass a
reference to the FormTreeView" means...

So, in Form1 (the form with the listview) I wrote:

FormTreeView ftv = new FormTreeView();
ftv.MyParentForm = this;

and added a method "fillListViewAddress"
Then, in the FormTreeView class I wrote:

public InstituteAdministrator MyParentForm;

and added the method:

internal void dataTreeView1_AfterSelect(object sender,
System.Windows.Forms.TreeViewEventArgs e)
{
MyParentForm.fillListViewAddress(e.Node.Tag.ToStri ng());
}

This seems to do what I have hoped for. Thanks a lot!

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Nov 17 '05 #3

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

Similar topics

4
by: Hal Vaughan | last post by:
I want to have a config file for my program, which means I need to know where the config file is. If I type: java myclass and it runs myclass.class, is there any way to obtain the location of...
1
by: Alex | last post by:
Hi all, Just been dabbling with java stored procedures and I'm having problems replacing System: db2 8.1.4 on RH 7.1 linux system 1). Look at java jdbc samples as supplied with db2 and run...
12
by: Tobias Froehlich | last post by:
Hi, I have a form called form1 on which there are a lot of checkBoxes (they form a 8x6 field). I'd like to create a class in a seperate .cs file which gives some control over these checkBoxes...
6
by: VM | last post by:
How can I fill up a listview with text file contents? My listview has two columns and the first column fills up with a while loop: while (myString != null) { myString = sr.Readline();...
3
by: Sven Groot | last post by:
This was posted by someone in comp.lang.c++, and later in microsoft.public.vstudio.general, but since I know Carl is in this group, and he's the one that should read this, I've reposted it here....
3
by: Andrew | last post by:
Hi all, I am still learning ASP.Net, and .Net in general. Though I feel I have much of the "basics" down, I am running into some gray areas in more advanced topics. My question is how I make...
2
by: vinodkus | last post by:
I am unable to make a class file in asp.net in version2.0 . when i make a class file class1.cs it gives the message it should be in App folder. First of all u tell me what is app folder. but when i...
3
by: kalpana84 | last post by:
hi, Am doing coding in c#,... actually i am creating four different classes in four different . And all classes has the same namespace. What to be done If i want invoke the method of one class...
2
by: Reggie | last post by:
Hi and TIA! I have a class file located in my root directory with all me web pages. I call/use the class and it works fine. I have no imports statements aspx or codebehind. My question is why? ...
0
by: xyndria | last post by:
Hello, im searching a ListView Sort Class: - sort items and subitems - sort Listviewitems in each ListviewGroup (not sorting the groups) - sort nummeric entries correct (like 1,2,100 and not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.