ListView problem

J

J_Max

Hello,

This might be a really easy question, but... I am
developing a simple Smart Device application that uses a
listview. I have a function that adds a item to the
listview - code is below. I use the type listviewitem,
selitem, on one form to modify the listviewitem, using a
timer, every second, and use selitem1 to modify items,
after they have ended the time on the timer form, from
the form that the listview is located - this way I don't
get the modify form and the timer form's item that they
are modifying mixed up. The items load into the listview
upon starting, using the function below. Then, a user
adds a row to the listview, and starts the time. However,
when the time is running, it doesn't update the row that
selitem is assigned to, instead, it writes to the first
item in the listview. In the back of my mind, I think it
might be a listview issue, not sorting it right, but I
don't know. I clear selitem before assigning it, so I'm
thinking that for some reason, it has not updated from
when it loaded all of the items in, but I don't know why
it wouldn't of updated from the first item.

Also, a side question, is there a way to sort a column of
a listview? One other, is there a ComboBox that you can,
before or after selecting an item, edit the text (Smart
Device App)?

Thanks for your help,

J_Max

Diagram of code:

Form1 (selitem, listview, selitem1, addlistitem)
| |
| |
/ \ / \
TimerForm (selitem) ModifyForm(selitem1)


Here is my code:

This is the function that I think that the problem is
located in:

public void AddListItem(String ItemDescription, String
ItemTime, String Billable, String Working, String Notes,
String DateStr, String STT, String SPT, bool item1)
{

ListViewItem item = new ListViewItem(ItemDescription);
item.SubItems.Add(Billable);
item.SubItems.Add(ItemTime);
item.SubItems.Add(Working);
item.SubItems.Add(Notes);
item.SubItems.Add(DateStr);
item.SubItems.Add(STT);
item.SubItems.Add(SPT);
if (item1 == true)
{
Form1.selitem1 = item;
}
else
{

//Form1.selitem = null;
Form1.selitem = new ListViewItem();
Form1.selitem = item;

}

Form1.self.items.Items.Insert(0, item);

}

Here's how I'm referencing it:
Form1.self.AddListItem(clients.SelectedItem.ToString
(), "00:00", billstr, working, "",
DateTime.Today.ToShortDateString(), mtime, "", o);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top