A
A
Abdula Magomedov2015-08-19 16:29:49
.NET
Abdula Magomedov, 2015-08-19 16:29:49

How to identify subItem in List View in C#?

There is such a problem. The List View is filled through a loop. Then the selected elements are selected, and operations are performed with them, after the operation is completed, the last cell in the row must be updated. Here's how to unambiguously determine which line you selected? It's just that I've been writing in C# for a couple of days, I don't know much. How does variable assignment happen in C#, in general everything is fine in java, everything is a pointer there, and saving a reference to some element is very simple, how about this? There is an option to add another column and write row numbers there, and refer to the row in which this value is, but in this case, you will have to completely iterate over the ListView each time. Is there any easy way to uniquely identify the selected line.... The fact is that after selection, all selected lines SelectedListItems are stored in a separate variable,

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Ai Lab, 2015-08-19
@Avarskiy


each listitem has a tag field in which you can write whatever you like, for example, the record ID (by which you can uniquely identify), the ID is easy to generate via GUID.NewGuid().ToString() the fact that this will help, because if you simply equate this array to a variable, then the variable will take a reference to the array, and thus your variable will change when the array changes, so if this is critical for you, it’s better to check it.

S
Stanislav Makarov, 2015-08-19
@Nipheris

> How does the assignment of variables happen in C#, in general everything is fine in java, everything is a pointer there, and it is very easy to save a reference to some element, how about this?
Read about reference-types (reference types) and value-types (value types) - assignment semantics depends on this.
What ListView are you talking about? WPF or WinForms?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question