I want to hide or disable Items with SetItemState(). The CListCtrl is in Report View.
It must be something like this m_List.SetItemState(1, DISABLE, DISABLE);
I searched but didnt find the right nState
If there is another solution than SetItemState, it also will be ok
Can anyone help me?
There is no item state to represent a disabled (grayed) item. See docs
The only way to solve this is your own implementation and using custom draw. That is the way I do it.
You can easily prevent the user to select an item when you trap LVN_ITEMCHANGING. Just filter the state Change to LVIS_SELECTED and return TRUE to prevent the change.
You can give visual feedback. I would derive a class CMFCListCtrl and override OnGetCellBkColor and OnGetCellTextColor methods to achieve it.
And I would override the its response to selection to unselect when selecting an unselectable item. However for this part, I am not so sure if it is doable.
Related
I have a CTreeCtrl and I filled it with content. Now I wanted to add checkboxes but JUST for certain ones. I've found the possibilty to activate checkboxes on the TreeCtrl with m_Tree.ModifyStyle(0, TVS_CHECKBOXES), but this adds a checkbox on each node/child on the whole Ctrl. Is it possible to turn this feature on, but just for certain ones?
All I found is the possibility to add three different pictures, catch the clickevent on a node and change the image. Is there an easier way? Let me know.
Thanks a lot,
jntme
I don't think that CTreeCtrl provide any method to add check boxes at specified node only.
Easiest way to do this is explain in following link.
http://www.tech-archive.net/Archive/VC/microsoft.public.vc.mfc/2005-10/msg00454.html.
please go through and let me know if you are facing problem.
You may be able to accomplish what you want with a custom draw tree control. But, you'll need to render the image states yourself. That could get messy because you'll need to account for all of the possible different states.
I have an UltraComboEditor (Infragistics control) and the user can input values on it. I used the AutoComplete property to do that.
But now I have a problem. I need to make sure that my user can delete a value that he wrote. I use the function canUndo but it not works.
How can I solve my problem?
Thank you.
I will try to add a ButtonLeft element, perhaps with a red cross image.
Let the user select an item from the combobox and then he/she will press the button element to trigger the action to delete the current selected element.
In the EditorButtonClick event you should ask for a confirm, search into your items collection and then remove the one selected.
I have a map application and a submenu which has dynamically added objects (i.e. points on a map) added to the submenu, depending on the layer that is loaded. I have the ability to hide each individual objects (i.e. a point) by clicking on the corresponding submenu item. Is there any way to organize the submenu? When there are a lot of points (i.e. 100) the entire submenu takes up the screen. Can I add a scrollbar to a submenu? I looked in the documentation, but couldn't find anything that support this feature.
From this bug report I was able to find out that you could do the following:
submenu->setStyleSheet("QMenu { menu-scrollable: 1; }");
Works like a charm.
There is no such possibility as far as I know.
Maybe you shouldn't use a sub menu for this but prefer a menu entry that show a Point manager GUI of your own which would have a QListWidget displaying all your points items.
I'm aware that this solution will break a (big?) part of your code but I don't see anything else.
I think you may be able to get the effect you want by creating and using your own QStyle subclass (via QApplication::setStyle()), and overriding the styleHint virtual method to return 1 when the StyleHint parameter passed in is SH_Menu_Scrollable. At least, that works for me when I create large QMenu objects and show them as popup menus.... It may also work for QMenus attached to the menu bar, but I havent tried that.
Whilst it is possible by subclassing the QMenu class to create a custom widget and going from there you're better off looking at a better way to display that information. You'll save yourself time and it'll be much easier for your users to not have to scroll through a big list of items in a small area.
I'm currently using the CListBox Control for MFC. Is it possible to retain the data inside the List Item but edit it, without deleting then re-adding it?
Thanks!
You can do this by extending CListBox. Check out this code project article.
There's no way to do this, unfortunately.
Even the native list box class doesn't provide any way to edit an entry, without removing and inserting.
The best you can do is extending the CListBox class, either by sub-classing or deriving from it.
The best way (if possible, sure), is replacing CListBox with CListCtrl
How to implement CEditListCtrl?. List control with edit capabality (Report/Grid view).
I have a list view in Report View. It has some values. I need to extend this to edit the values present in the list view.
I declared a class which inherits from CListCtrl. And I have handled the two Window messages to start and end the edit. Upon getting the messages I am displaying a Text box. But I am not getting the control inside these message handlers. Is there a way to know the reason?
Or Is there a other way to implement this.
There are some neat grid controls on Code Project which might help:
http://www.codeproject.com/KB/miscctrl/gridctrl.aspx
http://www.codeproject.com/KB/library/gridprojects.aspx
http://www.codeproject.com/KB/MFC/UltimateGrid.aspx
Thanks for all answers
I have done it easily.
I have handled the WM_LBUTTONDOWN. This handler pops up the edit box to get the new
value for the field
Handled LVN_ENDLABELEDIT to know the end of update.
After receiving the above message, updated the values.
“One thing I forgotten was to set the flag in the resource view for CListCtrl (Edit Labels to TRUE)”
We have to implement OnPaint() (in CListCtrl's derived class) also otherwise the UI won't update properly
You need to use a CComboBox which is basically a combined CEdit and CListCtrl
This question was also asked here:
How to edit columns in-place with CListCtrl?
You can read my answer on that page.