473,383 Members | 1,919 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,383 software developers and data experts.

Tag property of List View Item

Jax
I understand that it's supposed to contain text, usually.
But as it takes an object can you be really cheeky and put
a very complex object in there instead?
Would any problems come from doing that?

jax
Nov 15 '05 #1
7 5249
Hi Jax,

No problems whatsoever.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"Jax" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
I understand that it's supposed to contain text, usually.
But as it takes an object can you be really cheeky and put
a very complex object in there instead?
Would any problems come from doing that?

jax

Nov 15 '05 #2
hmmm I dunno, it's giving me grief.
Seems to turning it into a value rather then a reference
or something.
I change other references to the same object but it stays
the same???
-----Original Message-----
Hi Jax,

No problems whatsoever.

--
Miha Markic - RightHand .NET consulting & software developmentmiha at rthand com

"Jax" <an*******@discussions.microsoft.com> wrote in messagenews:04****************************@phx.gbl...
I understand that it's supposed to contain text, usually. But as it takes an object can you be really cheeky and put a very complex object in there instead?
Would any problems come from doing that?

jax

.

Nov 15 '05 #3
Hi,

Tag is an object reference thus it stores the reference and does more
nothing to it.
What exactly is your problem?
Can you give us an example?

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

<an*******@discussions.microsoft.com> wrote in message
news:05****************************@phx.gbl...
hmmm I dunno, it's giving me grief.
Seems to turning it into a value rather then a reference
or something.
I change other references to the same object but it stays
the same???
-----Original Message-----
Hi Jax,

No problems whatsoever.

--
Miha Markic - RightHand .NET consulting & software

development
miha at rthand com

"Jax" <an*******@discussions.microsoft.com> wrote in

message
news:04****************************@phx.gbl...
I understand that it's supposed to contain text, usually. But as it takes an object can you be really cheeky and put a very complex object in there instead?
Would any problems come from doing that?

jax

.

Nov 15 '05 #4
Jax
Thanks for your attention Miha,

Okay i'll try to keep it brief:

Imagine a form with a listview on the left.
In the background of the form there is an objerct called
theCase of custom type Case.
This contains an arraylist of references to all customer
objects.
The list view on the left represent all the customers, if
you click add customer this happens.

private void btnAddApplicant_Click(object sender,
System.EventArgs e)
{
ready = true;
ctr++;
Customer c = new Customer();
c.PersonalDetails.FirstName = "Name";
c.PersonalDetails.SecondName = "Me" + ctr.ToString();
theCase.Customers.Add(c);
ListViewItem lvi = new ListViewIte
(c.PersonalDetails.FirstName + " " +
c.PersonalDetails.SecondName, 0);
lvi.Tag = (object)c;
lvi.Selected = true;
this.lstCustomers.Items.Add(lvi);
}
So I put the reference into theCase as well as the Tag of
the listview.

If the selected index of the listview changes this happens.

if(this.lstCustomers.SelectedItems != null)
{
if(this.lstCustomers.SelectedItems.Count>0)
{
if(ready)
{
this.txtPersonalC1FirstName.Focus();
SaveCustomer();
theCustomer = (Customer) lstCustomers.SelectedItems[0].Tag;
this.PopulateFromCustomer(theCustomer);
foreach(ListViewItem listItems in lstCustomers.Items)
{
listItems.ImageIndex = 0;
}
lstCustomers.SelectedItems[0].ImageIndex = 1;
if(theCase.Customers.Count<2)
{
this.btnCopyAddresses.Visible = false;
this.btnCopyDependants.Visible = false;
}
else
{
this.btnCopyAddresses.Visible = true;
this.btnCopyDependants.Visible = true;
}
CreateSelfCertTable();
RefreshCopyCombos();
}
CreateSelfCertTable();
RefreshCopyCombos();
}
}
}

Save Customer does this.

private void SaveCustomer()
{
foreach(ListViewItem lvi in this.lstCustomers.Items)
{
if(lvi.ImageIndex == 1)
{
theCustomer = this.SaveCustomerFromForm();
lvi.Text = theCustomer.PersonalDetails.FirstName + " " +
theCustomer.PersonalDetails.SecondName;
lvi.Tag = (object)theCustomer;
break;
}
}
}

Do you remember at the top when I created the objects I
put a refrence in theCase custom type of Case.
Thing is is that I pass this object to my copyCommand form
and it has customers with their inital names ("Name Me1")
rather then the names i've put on since then.

With the load and the save method i have twined in with
the selected item changed event I can see that I am making
changes and these are being registered with the Customer
object as they are loading out all the details corrctly.

Any idea why theCase has outofdate references?
If you've got this far I thank you for your patience. :)
jax
-----Original Message-----
Hi,

Tag is an object reference thus it stores the reference and does morenothing to it.
What exactly is your problem?
Can you give us an example?

--
Miha Markic - RightHand .NET consulting & software developmentmiha at rthand com

<an*******@discussions.microsoft.com> wrote in message
news:05****************************@phx.gbl...
hmmm I dunno, it's giving me grief.
Seems to turning it into a value rather then a reference
or something.
I change other references to the same object but it stays the same???
>-----Original Message-----
>Hi Jax,
>
>No problems whatsoever.
>
>--
>Miha Markic - RightHand .NET consulting & software

development
>miha at rthand com
>
>"Jax" <an*******@discussions.microsoft.com> wrote in

message
>news:04****************************@phx.gbl...
>> I understand that it's supposed to contain text,

usually.
>> But as it takes an object can you be really cheeky
and put
>> a very complex object in there instead?
>> Would any problems come from doing that?
>>
>> jax
>
>
>.
>

.

Nov 15 '05 #5
HI Jax,

I could be wrong, though (near the end):
theCustomer = this.SaveCustomerFromForm();
lvi.Text = theCustomer.PersonalDetails.FirstName + " " +
theCustomer.PersonalDetails.SecondName;
lvi.Tag = (object)theCustomer;
You are assigning new customer to tag while theCase still has old reference
(to old customer).
Is this what you are missing?

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

"Jax" <an*******@discussions.microsoft.com> wrote in message
news:07****************************@phx.gbl... Thanks for your attention Miha,

Okay i'll try to keep it brief:

Imagine a form with a listview on the left.
In the background of the form there is an objerct called
theCase of custom type Case.
This contains an arraylist of references to all customer
objects.
The list view on the left represent all the customers, if
you click add customer this happens.

private void btnAddApplicant_Click(object sender,
System.EventArgs e)
{
ready = true;
ctr++;
Customer c = new Customer();
c.PersonalDetails.FirstName = "Name";
c.PersonalDetails.SecondName = "Me" + ctr.ToString();
theCase.Customers.Add(c);
ListViewItem lvi = new ListViewIte
(c.PersonalDetails.FirstName + " " +
c.PersonalDetails.SecondName, 0);
lvi.Tag = (object)c;
lvi.Selected = true;
this.lstCustomers.Items.Add(lvi);
}
So I put the reference into theCase as well as the Tag of
the listview.

If the selected index of the listview changes this happens.

if(this.lstCustomers.SelectedItems != null)
{
if(this.lstCustomers.SelectedItems.Count>0)
{
if(ready)
{
this.txtPersonalC1FirstName.Focus();
SaveCustomer();
theCustomer = (Customer) lstCustomers.SelectedItems[0].Tag;
this.PopulateFromCustomer(theCustomer);
foreach(ListViewItem listItems in lstCustomers.Items)
{
listItems.ImageIndex = 0;
}
lstCustomers.SelectedItems[0].ImageIndex = 1;
if(theCase.Customers.Count<2)
{
this.btnCopyAddresses.Visible = false;
this.btnCopyDependants.Visible = false;
}
else
{
this.btnCopyAddresses.Visible = true;
this.btnCopyDependants.Visible = true;
}
CreateSelfCertTable();
RefreshCopyCombos();
}
CreateSelfCertTable();
RefreshCopyCombos();
}
}
}

Save Customer does this.

private void SaveCustomer()
{
foreach(ListViewItem lvi in this.lstCustomers.Items)
{
if(lvi.ImageIndex == 1)
{
theCustomer = this.SaveCustomerFromForm();
lvi.Text = theCustomer.PersonalDetails.FirstName + " " +
theCustomer.PersonalDetails.SecondName;
lvi.Tag = (object)theCustomer;
break;
}
}
}

Nov 15 '05 #6
Jax
Miha,

You are right, you are awesome!
Thankyou soooooo much that's sorted EVERYTHING!
You the man!

a very happy jax.
-----Original Message-----
HI Jax,

I could be wrong, though (near the end):
theCustomer = this.SaveCustomerFromForm();
lvi.Text = theCustomer.PersonalDetails.FirstName + " " +
theCustomer.PersonalDetails.SecondName;
lvi.Tag = (object)theCustomer;
You are assigning new customer to tag while theCase still

has old reference(to old customer).
Is this what you are missing?

--
Miha Markic - RightHand .NET consulting & software developmentmiha at rthand com

"Jax" <an*******@discussions.microsoft.com> wrote in messagenews:07****************************@phx.gbl...
Thanks for your attention Miha,

Okay i'll try to keep it brief:

Imagine a form with a listview on the left.
In the background of the form there is an objerct called
theCase of custom type Case.
This contains an arraylist of references to all customer
objects.
The list view on the left represent all the customers, if you click add customer this happens.

private void btnAddApplicant_Click(object sender,
System.EventArgs e)
{
ready = true;
ctr++;
Customer c = new Customer();
c.PersonalDetails.FirstName = "Name";
c.PersonalDetails.SecondName = "Me" + ctr.ToString();
theCase.Customers.Add(c);
ListViewItem lvi = new ListViewIte
(c.PersonalDetails.FirstName + " " +
c.PersonalDetails.SecondName, 0);
lvi.Tag = (object)c;
lvi.Selected = true;
this.lstCustomers.Items.Add(lvi);
}
So I put the reference into theCase as well as the Tag of the listview.

If the selected index of the listview changes this happens.
if(this.lstCustomers.SelectedItems != null)
{
if(this.lstCustomers.SelectedItems.Count>0)
{
if(ready)
{
this.txtPersonalC1FirstName.Focus();
SaveCustomer();
theCustomer = (Customer) lstCustomers.SelectedItems [0].Tag; this.PopulateFromCustomer(theCustomer);
foreach(ListViewItem listItems in lstCustomers.Items)
{
listItems.ImageIndex = 0;
}
lstCustomers.SelectedItems[0].ImageIndex = 1;
if(theCase.Customers.Count<2)
{
this.btnCopyAddresses.Visible = false;
this.btnCopyDependants.Visible = false;
}
else
{
this.btnCopyAddresses.Visible = true;
this.btnCopyDependants.Visible = true;
}
CreateSelfCertTable();
RefreshCopyCombos();
}
CreateSelfCertTable();
RefreshCopyCombos();
}
}
}

Save Customer does this.

private void SaveCustomer()
{
foreach(ListViewItem lvi in this.lstCustomers.Items)
{
if(lvi.ImageIndex == 1)
{
theCustomer = this.SaveCustomerFromForm();
lvi.Text = theCustomer.PersonalDetails.FirstName + " " +
theCustomer.PersonalDetails.SecondName;
lvi.Tag = (object)theCustomer;
break;
}
}
}

.

Nov 15 '05 #7
Jax,

1st) you do not need to cast to an (Object) when you assign a tag.
Everything is an object.

2nd) I've had discrepencies with putting objects on to tags before. The
best way I've found is to assign the tag everytime the object changes.

Hope this helps

Marco

"Jax" <an*******@discussions.microsoft.com> wrote in message
news:07****************************@phx.gbl...
Thanks for your attention Miha,

Okay i'll try to keep it brief:

Imagine a form with a listview on the left.
In the background of the form there is an objerct called
theCase of custom type Case.
This contains an arraylist of references to all customer
objects.
The list view on the left represent all the customers, if
you click add customer this happens.

private void btnAddApplicant_Click(object sender,
System.EventArgs e)
{
ready = true;
ctr++;
Customer c = new Customer();
c.PersonalDetails.FirstName = "Name";
c.PersonalDetails.SecondName = "Me" + ctr.ToString();
theCase.Customers.Add(c);
ListViewItem lvi = new ListViewIte
(c.PersonalDetails.FirstName + " " +
c.PersonalDetails.SecondName, 0);
lvi.Tag = (object)c;
lvi.Selected = true;
this.lstCustomers.Items.Add(lvi);
}
So I put the reference into theCase as well as the Tag of
the listview.

If the selected index of the listview changes this happens.

if(this.lstCustomers.SelectedItems != null)
{
if(this.lstCustomers.SelectedItems.Count>0)
{
if(ready)
{
this.txtPersonalC1FirstName.Focus();
SaveCustomer();
theCustomer = (Customer) lstCustomers.SelectedItems[0].Tag;
this.PopulateFromCustomer(theCustomer);
foreach(ListViewItem listItems in lstCustomers.Items)
{
listItems.ImageIndex = 0;
}
lstCustomers.SelectedItems[0].ImageIndex = 1;
if(theCase.Customers.Count<2)
{
this.btnCopyAddresses.Visible = false;
this.btnCopyDependants.Visible = false;
}
else
{
this.btnCopyAddresses.Visible = true;
this.btnCopyDependants.Visible = true;
}
CreateSelfCertTable();
RefreshCopyCombos();
}
CreateSelfCertTable();
RefreshCopyCombos();
}
}
}

Save Customer does this.

private void SaveCustomer()
{
foreach(ListViewItem lvi in this.lstCustomers.Items)
{
if(lvi.ImageIndex == 1)
{
theCustomer = this.SaveCustomerFromForm();
lvi.Text = theCustomer.PersonalDetails.FirstName + " " +
theCustomer.PersonalDetails.SecondName;
lvi.Tag = (object)theCustomer;
break;
}
}
}

Do you remember at the top when I created the objects I
put a refrence in theCase custom type of Case.
Thing is is that I pass this object to my copyCommand form
and it has customers with their inital names ("Name Me1")
rather then the names i've put on since then.

With the load and the save method i have twined in with
the selected item changed event I can see that I am making
changes and these are being registered with the Customer
object as they are loading out all the details corrctly.

Any idea why theCase has outofdate references?
If you've got this far I thank you for your patience. :)
jax
-----Original Message-----
Hi,

Tag is an object reference thus it stores the reference

and does more
nothing to it.
What exactly is your problem?
Can you give us an example?

--
Miha Markic - RightHand .NET consulting & software

development
miha at rthand com

<an*******@discussions.microsoft.com> wrote in message
news:05****************************@phx.gbl...
hmmm I dunno, it's giving me grief.
Seems to turning it into a value rather then a reference
or something.
I change other references to the same object but it stays the same???
>-----Original Message-----
>Hi Jax,
>
>No problems whatsoever.
>
>--
>Miha Markic - RightHand .NET consulting & software
development
>miha at rthand com
>
>"Jax" <an*******@discussions.microsoft.com> wrote in
message
>news:04****************************@phx.gbl...
>> I understand that it's supposed to contain text,
usually.
>> But as it takes an object can you be really cheeky and put
>> a very complex object in there instead?
>> Would any problems come from doing that?
>>
>> jax
>
>
>.
>

.

Nov 15 '05 #8

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

Similar topics

0
by: Anushya | last post by:
Hi I am trying to add image items to listview. Here how to handle if i need to add images?? Pls go thru the code. In the form where i have used this virtualListView, have handled...
2
by: louise raisbeck | last post by:
Hi there. I am a little confused. SelectedValue is a property of ListBox and dropdownlist. However it isnt in the list of properties in intellisence (html view i am not talking about code behind...
6
by: Altman | last post by:
I would like to use an indexed property to access my private array of user controls. If I don't use an indexed property, the property will show up in my Properties Window during development. Is...
0
by: Brian Henry | last post by:
Since no one else knew how to do this I sat here all morning experimenting with this and this is what I came up with... Its an example of how to get a list of items back from a virtual mode list...
0
by: Brian Henry | last post by:
Here is another virtual mode example for the .NET 2.0 framework while working with the list view. Since you can not access the items collection of the list view you need to do sorting another...
3
by: Brian Henry | last post by:
So what is the easiest way to do this? I have one list view with a list of items (in detail view and with about 20 sub items) and a second list view that will take the items they drag from the...
5
by: Kimmo Laine | last post by:
Hi is there a way to change propertys attribute from the code? Letīs say that i have the following property in my class: public int Count } Is there a way to change the displayname, from...
8
by: Papa.Coen | last post by:
Contrary to what the title might make you believe; this is not a n00b question. I recently came across a problem with using a property which made me question the way I use/see properties in...
1
by: shapper | last post by:
Hello, I have a class where I created various controls. One of the controls have a property which is a generic list of WebControl. Then in web site page I have something like: Dim a As New...
2
by: Mohit | last post by:
Hi all, I am working on a windows application with a list view on a form. Now I wanted to show hand cursor when mouse is over list view item and default(arrow) cursor at other places. List...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.