Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does MFC have a built in grid control?

First what I want: The ability to display a grid with multiple columns, each cell having a custom render callback. So you might use such a control to display your inventory in a game, or something like the behaviour in Google Chrome where it shows a grid of popular pages you visit.

I've been playing with CListCtrl and while I can get custom rendering ability on each item, I can't get it work with columns - having say 3 items per row. The control has column-related methods but I think these are specifically for the built-in functionality where different attributes of an item are shown automatically in each column... not for providing a generic grid control.

So, does such functionality exist in MFC? If not then I wonder if the easiest approach is for me to actually insert each of the rows as an Item... and then the custom rendering draws the multiple cells in the row, I could also do custom UI to support clicking on the cells.

But what I really want is to be able to create a custom control, and add this as an item to a list - like in Flex for instance - so I/O etc is automatically handled.

Any advice/information welcome...

like image 942
Mr. Boy Avatar asked Oct 27 '09 10:10

Mr. Boy


3 Answers

Dundas has thrown some of its (excellent) components in the public domain. Their Ultimate Grid is available on CodeProject.

like image 56
Serge Wautier Avatar answered Sep 22 '22 03:09

Serge Wautier


I'm not aware of a built-in control, but I think you should take a look at this. The article is describing in detail the functionality of a fully featured MFC grid control, derived from CWnd, for displaying tabular data.

like image 24
luvieere Avatar answered Sep 19 '22 03:09

luvieere


YOUR_LIST_CONTROL.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_INFOTIP|LVS_EX_GRIDLINES);

I think it will help you (SetExtendedStyle).

like image 41
nandi Avatar answered Sep 22 '22 03:09

nandi