I have listview and i have checkboxes enabled in the listview How would i check all the checkboxes in the listview and deselect?
Thank you
I think this will help you:
if (chkSelectAll.IsChecked == true) {
for (int y = listitem.Items.Count - 1; y >= 0; y--) {
System.Windows.Controls.CheckBox chk= (System.Windows.Controls.CheckBox)listitem.Items[y];
chk.IsChecked = true;
}
}
This code goes inside your event.
You should loop through the Items collection and set the Checked property for each one.
Related
I have subclassed UIRefreshControl to make my own, and I can manage everything except one thing :
The default spinner is always visible, and is of course in the middle of everything I've done in my custom implementation.
I can't find the spinner property or whatever it is I need to put to a clear color, can anyone help me on this?
To hide spinner loader in a UIRefreshControl, set the .tintColor property to a clear color.
e.g. (Swift):
mRefreshControl.tintColor =.clear
For 2023, .tintColor = .clear works fine.
Historic answer:
Swift 4, Swift 5
Bug fix
From time to time only this code doesn't work properly:
refreshControl.tintColor = .clear – first reload shows the indicator :(
This fixes this bug:
refreshControl.tintColor = .clear
refreshControl.subviews.first?.alpha = 0
Override didMoveToSuperview to hide the spinner's superview.
Swift version:
override func didMoveToSuperview() {
super.didMoveToSuperview()
guard let _ = superview else { return }
self.subviews.first?.alpha = 0 // set hidden = true did not work
}
Objective-C version:
- (void)didMoveToSuperview {
[super didMoveToSuperview];
if (self.superview != nil && self.subviews.count > 0) {
self.subviews[0].alpha = 0;
}
}
You may want to do more checks rather than just using the first subview.
I am having a tree control where initially I had set it style in OnInitDialog as follows,
BOOL OnInitDialog()
{
CPropertyPage::OnInitDialog();
//Setting Treecontrol with TVS_CHECKBOXES style
HWND m_hTreeWnd = ::GetDlgItem(m_hWnd,IDC_TREE);
DWORD dwStyle = GetWindowLong(m_hTreeWnd,GWL_STYLE);
dwStyle |= (TVS_CHECKBOXES);
SetWindowLongPtr(m_hTreeWnd,GWL_STYLE,dwStyle);//CTreeCtrl m_hTreeWnd;
//Now I had initialized the tree control and I am want only few items of the tree to have
//checkboxes,In order to achieve that I did it as follows(Removing checkboxes where not required)
tvInsertItem.hParent = NULL;
tvInsertItem.hInsertAfter = TVI_ROOT;
tvInsertItem.item.mask = TVIF_TEXT|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
tvInsertItem.item.pszText = L"Name"
hParentItemHandle = m_TreeCtrl.InsertItem(&tvInsertItem);
//Removal of checkboxes for the above item
tvItem.hItem = hParentItemHandle;
tvItem.mask = TVIF_TEXT|TVIF_STATE|TVIF_SELECTEDIMAGE;
tvItem.stateMask = TVIS_STATEIMAGEMASK;
tvItem.state = 0;
tvItem.pszText = szCommonModel;
m_TreeCtrl.SetItem(&tvItem);
}
Everything is fine I removed checkbox in which ever the node it is not required.And having checkbox where they are required.
All of a sudden I noticed this issue i.e, after selecting an item in the tree control which does not have checkbox ,now if
I press "space bar"then a checkbox is getting append to that item.
I want avoid the checkbox when I press space bar.
To avoid checkbox I tried this but did not work.
BOOL CTreeControlDlg::OnTvnItemChangingTree(UINT i,NMHDR *pNMHDR, LRESULT *pResult)
{
NMTVITEMCHANGE *pNMTVItemChange = reinterpret_cast<NMTVITEMCHANGE *>(pNMHDR);
HTREEITEM hTree = pNMTVItemChange->hItem;
UINT ChangItem = pNMTVItemChange->uStateNew;
UINT ChangItem1 = pNMTVItemChange->uStateOld;
UINT ItemState = m_TreeCtrl.GetItemState(hTree, TVIS_STATEIMAGEMASK);
if(98 == ItemState)//98 is the thing I observed while debugging this is not correct I know.
return FALSE;
return TRUE;
}
I am bit confused how do we get the state image mask TVIS_STATEIMGAEMASK and how do we make that check whether the item has this mask or not .
Can anyone please suggest me a way to acheive this.
In MFC how to remove a menu-item of POPUP type. RemoveMenu() either take ID or position. Since, there is no ID for POPUP menu, option left is by using position.
But I am not getting how and where I can call RemoveMenu().
File Edit Test
Test_submenu_1
Test_submenu_2
Test_submenu_3 > submenu_3_item_1
Test_submenu_4
Test_submenu_5
I want to remove Test_submenu_3? I am not getting how do find CMenu object for Test so that I can call RemoveMenu() by passing position "2" for submenu_3_item_1.
Any suggestion for doing this will be greatly appreciated.
Thanks!
You cannot use LoadMenu, since this function does just that.
After modifying loaded menu it is killed when menu object used to load it goes out of scope. You have to modify menu that is currently used.
Your menu is a popup part of the main menu, second in position. It contains 5 items and second one is another popup. To my understanding, you want to remove this item and popup of this item.
To make it work you will have to ask main window for the current menu:
CMenu* pMenu = GetMenu(); // get the main menu
CMenu* pPopupMenu = pMenu->GetSubMenu(2);//(Test menu with item....)
pPopupMenu->RemoveMenu(2, MF_BYPOSITION);
Of course, this code is from the main frame. If you want to use it elsewhere, you will have to access all using pointer to the main frame.
Try the below. You get the Test sub-menu first (index 2), then once you have that you tell it to remove its Test_submenu_3 submenu by position (also 2).
CMenu topMenu;
topMenu.LoadMenu(IDR_YOUR_MENU);
CMenu& testSubMenu = *topMenu.GetSubMenu(2);
testSubMenu.RemoveMenu(2,MF_BYPOSITION);
'Test' is the 3rd menu item (by position) on the top level menu. It's just been rendered horizontally rather than vertically. Assuming you have a handle to the top level menu use the same code you'd use to the get the sub menus as you would to get the 'Test' menu.
You can use this below code to remove the submenu, by comparing name
bool RemoveSubmenu(CMenu * pMenu) {
for (int pos = 0; pos < pMenu->GetMenuItemCount(); pos++) {
wchar_t *name = new wchar_t[mf.cch + 1];
MENUITEMINFO mf;
ZeroMemory(&mf, sizeof(mf));
mf.cbSize = sizeof(mf);
mf.fMask = MIIM_SUBMENU | MIIM_FTYPE | MIIM_STRING;
mf.fType = MIIM_STRING;
mf.dwTypeData = NULL;
if (!GetMenuItemInfo(pMenu->m_hMenu, pos, TRUE, &mf))
break;
if (mf.hSubMenu != NULL){
mf.fMask = MIIM_TYPE;
mf.fType = MFT_STRING;
++mf.cch;
mf.dwTypeData = (LPSTR)name;
if (!GetMenuItemInfo(pMenu->m_hMenu, pos, TRUE, &mf)){
bRet = false;
break;
}
//
// compare sub menu name (i.e mf.dwTypeData) here, do the required
// modifications
//
pMenu->RemoveMenu(pos, MF_BYPOSITION);
bRet = true;
break;
}
}
}
I have an iOS app built on CoreData with tableviews and detailviews of the objects.
When in the detailview I would like to swipe horizontally to get the detail view of the next object.
I found PageControl and scrollview. But this is going to be for over 100 objects in the model.
Does anyone have a good sample of this or resource on how to do this.
Thanks
Michael
You could make individual views for each Core Data Object, then place those views on a UIScrollView.
You would need to set the contentSize:
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * allYourViews.count, scrollView.frame.size.height);
Then loop over all your views and add them to the scrollView:
for(int i = 0; i < allYourViews.count; i++) {
CGRect frame;
frame.origin.x = scrollView.frame.size.width * i;
frame.origin.y = 0;
frame.size = scrollView.frame.size;
if(allYourViews.count > 0) {
UIView* someView = (UIView *)allYourViews[i];
someView.frame = frame;
[scrollView addSubview:someView];
}
}
For more information and how to make it scroll nicely, check this tutorial:
http://www.iosdevnotes.com/2011/03/uiscrollview-paging/
( I don't know how this will perform :-)
I have buttons with id's button1, button2, button3, etc.
I have a for loop that i need to loop starting with a number and i need to enable buttons based on my loop. I need help taking my string button1 and making that the id "button1" so i can use the button property's.
Any help would be greatly appreciated.
Thanks!
You should be able to iterate as such:
for (var i:uint = 1; i <= 3; i++)
{
var element:IVisualElement = this["group" + i];
}
You don't denote whether this Spark or Halo, but clearly substitute IVisualElement with the type of your choice. (Button, UIComponent, DisplayObject...)