BartekW
Topic Author
Posts: 53
Joined: 24 Mar 2021, 14:33

Grid view in C++

14 Apr 2021, 12:12

Can someone explain how to add UserControl to grid in C++?

I have some code:
contentGrid = FindName<Noesis::Grid>("TestGrid");

	UserControl* userControl = new TabControlMenu();
	contentGrid->AddVisualChild(userControl);
And it throw error: Elements is protected by method AddVisualChild.
I made something like this in c# in the past, but dont remember exactly how.
How to do this? I want to generate content in grid.
 
User avatar
jsantos
Site Admin
Posts: 3905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Grid view in C++

14 Apr 2021, 12:50

Being Grid a Panel, you need to use its Children Property:
Ptr<UserControl> userControl = MakePtr<TabControlMenu>();
grid->GetChildren()->Add(userControl);
And in case you need to set row and column:
Grid::SetColumn(userControl, x);
Grid::SetRow(userControl, y);
Please, note that the way you were creating your control is not correct and will leak memory. Make sure to read our C++ Architecture Guide.
 
BartekW
Topic Author
Posts: 53
Joined: 24 Mar 2021, 14:33

Re: Grid view in C++

14 Apr 2021, 13:37

Being Grid a Panel, you need to use its Children Property:
Ptr<UserControl> userControl = MakePtr<TabControlMenu>();
grid->GetChildren()->Add(userControl);
And in case you need to set row and column:
Grid::SetColumn(userControl, x);
Grid::SetRow(userControl, y);
Please, note that the way you were creating your control is not correct and will leak memory. Make sure to read our C++ Architecture Guide.
Thanks for reply, I have the compiler error, it throws: Pointer to uncomplited type is not allowed.
It throws on my grid pointer.
My grid pointer is Grid* type
 
BartekW
Topic Author
Posts: 53
Joined: 24 Mar 2021, 14:33

Re: Grid view in C++

14 Apr 2021, 13:53

Ok I needed include UIElementCollection header :)
 
User avatar
jsantos
Site Admin
Posts: 3905
Joined: 20 Jan 2012, 17:18
Contact:

Re: Grid view in C++

14 Apr 2021, 14:02

Yes, make sure you are including the corresponding headers or just use the PCH header that includes everything.

Who is online

Users browsing this forum: Google [Bot], vinick and 64 guests