How do I add Button to each row in list view

1
2
3
4
5
6
7
8
9
10
11
12
13
14
for (k = 0; k < PrimeSize; k++)
			{
				Item = gcnew ListViewItem(k.ToString());
				Item->SubItems->Add(HTPtr->TableArray[k].ToString());
				Item->SubItems->Add(HTPtr->OrderArray[k].ToString());

				Item->SubItems->Add(Title);

//This is the button I want to add I keep getting an error saying "listviewitems" has no member 
				Item->SubItems->Controls->Add(this->btnSelect);

				HashTableListView->Items->Add(Item);
			}
Item->Subitems is a ListViewSubItemCollection Class and you can add only String or ListviewItems to it.
To add a Button you need to set the Button->Parent to the Listview and find the right position for it it. Here's a example in C# maybe you can adopt it.
https://www.codeproject.com/Articles/9188/Embedding-Controls-in-a-ListView

Thanks reading it now,

i'm fairly new to c++ especially with forms would the syntax be the same?

honestly don't know how to start implementing it
Well the syntax is different.
C++
1
2
Button^ button = gcnew Button();
button->Text = "Some text";

C#
1
2
Button button = new Button();
button.Text = "Some Text";


I think this project might be a bit difficult for a beginner.

To Learn C++ / CLR from scratch is usually recommend this book.
https://www.amazon.com/Visual-NET-Platform-Books-Professionals/dp/1430210532/ref=sr_1_1?s=books&ie=UTF8&qid=1522843407&sr=1-1&keywords=C%2B%2B+Stephen+Fraser
or if you prefer tutorials
http://www.functionx.com/vccli/index.htm
Last edited on
Thanks for replying, I just used one button that selects each row by the name
Topic archived. No new replies allowed.