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...)
Related
I am using c1truedbgrid. I have columns added in the grid with one column having button which is displayed is every row. I need to disable the button in a particular row depending on some business logic. How this can be done?
I am not sure why there aren't any answer.
Its fairly simple. Lets say I want to disable the buttons from those rows where ID is even.
for(int i = 0; i< c1truedbgridobject.Splits[0].Rows.Count; i++)
{
if(Convert.ToInt32(c1truedbgridobject[i,1].ToString())%2 == 0)
{
//Disable here
}
}
However the disable part is dependent on how you are adding button to a cell. Since add button is referenced to whole column and not to a particular cell.
Anyhow using a OwnerDrawCell is also an option.
EDIT:
This seems as a limitation of C1TrueDBGrid. You may use C1FlexGrid as an alternative.
You need to make property of that column as "locked=True" as Below example when you initializing grid.
C1TrueDbGridName.Splits(0).DisplayColumns("YourColumnNameHavingButton").Locked = True
it will make your row not to be editable
I want to implement a list in Android that contains some customized views.
My problem is that I want the the views will be put one after the other with a little overlap between them. like in the following schema:
I also want to control this overlap in such a way that when the user clicks on one of the items, they will move apart from each other.
I tried to extend ListView but it seems to be very obscured, any suggestions?
Edit:
This can be more clear:
I did it by setting the divider height to -50dp.
this is exactly what I want to achieve, but somehow it doesn't reflect on my app.
I managed to achieve this by using scroll view with a single relative layout as a child.
I then dynamically place the views by defining a rule and margin:
for (int i = 0; i < 30; i++) {
TextView tv = new TextView(context);
tv.setText("Text \n Text" + i);
tv.setBackgroundColor(i % 2 == 0 ? Color.RED : Color.GREEN);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
lp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
lp.leftMargin = 0;
lp.topMargin = (i * 45);
rl.addView(tv, lp);
}
Later, you can control the positioning of the sub-views by changing their y value (for example: if you want to add animation).
This is the final result:
This can probably be achieved by using the Camera.setTranslate function. See Android: Vertical ListView with overlaped rows and Android: vertical 3d listview for similar questions (with solutions)
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;
}
}
}
This question already has answers here:
Jquery selectable for range selection (slider behaviour)
(3 answers)
Closed 2 years ago.
I want to use something similar to jQuery UI's Selectable. But it operates strictly on a dragged rectangle, and I want something that operates on a flow layout (like selecting text).
As an example, if I go to the Selectable "display as grid" demo, click on "3", and drag to "6", Selectable selects everything in that rectangle:
What I want instead is for it to select all the numbers from 3 to 6. (It should probably also disable the dotted-line rectangle as well, since it doesn't make sense for this type of selection.) Like this (again dragging from 3 to 6):
Selectable has an event that it fires as items are selected and deselected during the drag, but I don't see any way to alter its "which items are selected" list from that event, or to plug in a custom "how do I tell which items should be selected?" algorithm.
How can I get Selectable to select items by logical order instead of by pixel position?
i think it may help you!
var indices = [];
$( "#selectable" ).selectable({
selecting: function(event, ui) {
indices.push($(ui.selecting).index());
select();
},
unselecting: function(event, ui) {
var index = $(ui.unselecting).index();
for(var i = 0; i < indices.length; i++)
if(indices[i] == index)
indices.splice(i, 1);
select();
}
});
function select() {
indices.sort(function(a,b){return a-b});
var start = indices[0];
var end = indices[indices.length - 1];
$('#selectable li').removeClass('ui-selecting');
$('#selectable li').filter(function() {
return $(this).index() >= start && $(this).index() <= end;
}).addClass('ui-selecting');
}
I put up a demo for this solution: http://jsfiddle.net/snyuan/TGekT/, and http://jsfiddle.net/snyuan/Yrgnv/. Just a reference.
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.