Add checkbox in second column in CLIstctrl in mfc - mfc

I want to add checkbox in second column and all check boxes need to checked in default. By adding LVS_EX_CHECKBOXES in Extended Style, the check box adding to first column.
I create ListCtrl using OnCreate();
m_ctLstCtrl.Create(WS_CHILD | WS_VISIBLE | LVS_REPORT ,listRect, this, IDC_TRENDLISTCTRL);
m_ctLstCtrl.SetExtendedStyle(m_ctLstCtrl.GetExtendedStyle() |LVS_EX_CHECKBOXES | LVS_EX_GRIDLINES| LVS_EX_FULLROWSELECT| LVS_EX_ONECLICKACTIVATE );
m_ctLstCtrl.InsertColumn(0,_T(""),LVCFMT_RIGHT,20);
m_ctLstCtrl.InsertColumn(1,_T("Visible"),LVCFMT_LEFT,50);
m_ctLstCtrl.InsertColumn(2,_T("Status"),LVCFMT_LEFT,50);
Edit: In another question, the answer is mentioning updating CListCtrl . But i need only moving first column check box to second column.Is that possible to do that? I tried CImageList to get Check box bitmap in second column. But as im new to using CLIstCtrl. i cannot find the solution.

Related

Winforms controlling controls

I couldn't think of a coherent search term for my problem so please forgive me if this has been asked before.
I have 24 combo boxes sitting on a panel control, displayed in 4 rows of 6.
After the user defines the value for each combo and hits the "go" button, I add all combo boxes to list so I can use the values in another section of my program.
The problem is that the order the comboboxes are added to the list is messed up, compared to their visual layout on the panel, and I would like to define the order. Currently, it adds the 9th combobox to the list first then the 20th, 2nd, 16th etc etc.
I tried TabIndex but that didnt work.
Before I manually rename and relabel all of the boxes, any other suggestions will be gratefully received.
The controls of your form exist in Controls collection of the container controls, for example when you add a Panel and a Button to a Form and two ComboBox to the Panel, then:
Form.Controls contains button1 and panel1
Panel.Controls contains comboBox1 and comboBox2
Controls are added to the Controls collection, with the same order that you add them to designer. Open designer.cs, look at the end of InitializeComponent to see the order.
You can also see/change the order using Document Outline window.
That said, now it should be obvious that panel1.Controls.OfType<ComboBox>() returns combo boxes with the same order that you see in Document Outline (or based on their z-index, and it doesn't have anything to do with their x/y placements).
You may want to order them based on TabIndex, or any other property that you like:
panel1.Controls.OfType<ComboBox>().OrderBy(x=>x.TabIndex)
Note
In general, if you are going to use those values for a search, instead of relying on the order of values, a much better idea is creating a SearchModel class which has a few properties, the set those properties to the selected value of the corresponding combo box (manually or using databinding) then pass the search model to the other classes.

Change label of QComboxBox without using lineEdit

Currently I want to implement a widget to allow user to enable/disbale all provided options of a QSet. So i took a combobox and added selectable items. So far so good, but how I can change text displayed in combobox? Currently all my items have just ItemIsUserCheckable and ItemIsEnabled as enabled flags (ItemIsSelectable is not enabled), so text of ComboBox is always text of first item. Instead I want as text "Flag1, Flag 3, Flag6" if there multiple flags and user enabled Flag 1, 3 and 6. But setCurrentText and setEditText requiring setEditable(true) or an custom lineEdit. But using an lineEdit is changing appearance. So is there another way?
I had a similar problem a while back, I ended up 'solving' it by adding an extra item to my model that was first in the list and always set as the current item. I then updated it's text to say 'Select items...' or 'X item(s) selected' as appropriate.

wxwidgets wxlistctrl edit specific column

OS: WIN 8
WX VERSION: 3.0.2
Having problem with wxListItem - wxListCtrl:
I have a wxListCtrl with 2 columns and with the following masks: wxLC_REPORT | wxLC_EDIT_LABELS | wxLC_SINGLE_SEL | wxLC_HRULES | wxLC_VRULES
Problem: I want to edit the labels in the 2nd column by mouse click but at the moment, a mouse click anywhere in a specified row only edits the 1st column.
why is that? what would I need to do to edit only the 2nd column and prevent column 1 from being edited?
I have checked the official documentation, but there is not much info on the mask, as I would like to think this might be a problem related to improper use of the appropriate MASK
Thanks
wxListCtrl only supports editing of its first column due to the same limitation in the native list view control used to implement it under MSW.
If you need all columns to be editable, consider wxDataViewCtrl or wxGrid. Unfortunately neither of them is native under MSW (see this table), but wxDVC doesn't look too bad, especially with the latest versions.

Ensuring column visibility in wxListCtrl

I want wxListCtrl in report mode and I want to lock one or more columns such that when you scroll left and right those columns remain visible at all times. For example:
| name | field1 | field2 | field3 |....|
When scrolled to the left I want it to be like:
| name | field3 | field 4 | ... |
I can't find a way to get this functionality.
I looked at wxGrid and it would if I set the row label to the name value, but first that's not exactly what is desired and second it makes the name non-editable. I need it to be editable.
There a way to get what I want?
I suggest faking it by using two controls side by side. One would hold the the non-scrolling column(s), the other would scroll. By carefully aligning them with minimal margins, they would look, at a glance, like one control. By handling the vertical scroll events in the parent, the vertical scrolling of both can be synchronized.
I would definitely use wxGrid rather than wxListCtrl since you get access to a much richer feature set.

How do I un-highlight a previously selected line in an MFC CListCtrl programmatically (VS 6)?

Does anyone know how to un-highlight a previously selected line in an MFC CListCtrl programmatically ?
To de-select the 20th item:
YourListCtrl.SetItemState(20, 0, LVIS_SELECTED);
Well, it doesn't work if the the List view is Report style ie multiple columns. Do you have any solution for that?
One can set the List property as:
m_ctlList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
which always selects the particular line when user clicks on that line, but if programmer deletes a line in the list view, the next row replaces the selected one and the row is un-highlighted.