I'm having a hard time trying to create my first ListCtrl with 2 columns and 2 Rows to study how it works.
I couldn't find any complete examples on the internet. The ones I always found missing, something in the code and they don't work.
But I ended up wondering what I could use for control!
I created a Struct with a Grid. Then I removed Struct, and left only the Grid.
That's when I thought instead of using a Grid I could use a simpler control.
I don't like the Grid because it doesn't correctly select the whole line, it's half pretending to be selected
In ListCtrl when selecting a row, it is perfectly selected without flaws, different from the grid
My Objective is to read a file that I have formed as a table, to the Control
As an example I would have 2 columns and 2 rows only
Then what I'll do is save the data in the file and read from the file.
The only thing this control will do is display the data, that's all.
Which one should I use for this purpose? At first I thought ListCtrl was good, but I was in doubt about DataViewCtrl.
And if someone knows how to do it, could they leave me a super simple example of a control like this with 2 columns and 2 rows, for me to study how it works so that I can then implement what I need!
Thank you to anyone who can help!
Help on ListCtrl Topic is solved
-
- Part Of The Furniture
- Posts: 7481
- Joined: Sat Apr 16, 2005 7:22 am
- Location: USA, Ukraine
Re: Help on ListCtrl
Hi,
How may rows/columns do you need?
Do youneed to use an additional controls inside? Like use a button in some cells.
Do you need to use DnD operation?
Thank you.
How may rows/columns do you need?
Do youneed to use an additional controls inside? Like use a button in some cells.
Do you need to use DnD operation?
Thank you.
-
- Moderator
- Posts: 19164
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
Re: Help on ListCtrl
Code: Select all
wxListCtrl *lc = new wxListCtrl(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT );
lc->AppendColumn( "col1" );
lc->AppendColumn( "col2" );
lc->AppendColumn( "col3" );
for(int i=0; i<20; i++ )
{
long item = lc->InsertItem( i, wxString::Format("item%d col%d", i, 0) );
lc->SetItem( i, 1, wxString::Format("item%d col%d", i, 1) );
lc->SetItem( i, 2, wxString::Format("item%d col%d", i, 2) );
}
Use the source, Luke!
-
- Earned some good credits
- Posts: 107
- Joined: Thu Apr 11, 2019 12:50 am
Re: Help on ListCtrl
2 Columns and 2 Lines as I informed in the question is already enough. But, The example that doublemax left already serves because I was able to mount a simple model with that
I will use nothing but plain text
I don't know what DnD is
The question left is whether to use ListCtrl or DataViewCtrl
-
- Earned some good credits
- Posts: 107
- Joined: Thu Apr 11, 2019 12:50 am
Re: Help on ListCtrl
This example was great to study! I can understand the basics now so I can study his documentation.doublemax wrote: ↑Wed May 13, 2020 4:36 pmCode: Select all
wxListCtrl *lc = new wxListCtrl(panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT ); lc->AppendColumn( "col1" ); lc->AppendColumn( "col2" ); lc->AppendColumn( "col3" ); for(int i=0; i<20; i++ ) { long item = lc->InsertItem( i, wxString::Format("item%d col%d", i, 0) ); lc->SetItem( i, 1, wxString::Format("item%d col%d", i, 1) ); lc->SetItem( i, 2, wxString::Format("item%d col%d", i, 2) ); }
I've even managed to do that. I learned how to use Insert and manually create the row and column texts
Code: Select all
ListCtrl->InsertColumn(0, "col1");
ListCtrl->InsertColumn(1, "col2");
ListCtrl->InsertColumn(2, "col3");
ListCtrl->InsertItem(0 , "Text1");
ListCtrl->SetItem (0, 1, "Text2");
ListCtrl->SetItem (0, 2, "Text3");
ListCtrl->InsertItem(1 , "Text1");
ListCtrl->SetItem (1, 1, "Text2");
ListCtrl->SetItem (1, 2, "Text3");
-
- Part Of The Furniture
- Posts: 7481
- Joined: Sat Apr 16, 2005 7:22 am
- Location: USA, Ukraine
Re: Help on ListCtrl
Hi
wxDVC is a very complex.
You should stick with WILL.
For the future reference - DnD is 'drag-and-drop'
Thank you.
wxDVC is a very complex.
You should stick with WILL.
For the future reference - DnD is 'drag-and-drop'
Thank you.
-
- Earned some good credits
- Posts: 107
- Joined: Thu Apr 11, 2019 12:50 am