w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
How can I keep items in ComboBox after close the application
You need to persist the data to a data store (either the database or the file system) so that the next time the application runs, then it can check the data store and display the items to the user.

Categories : Vb.Net

How do I add different icons to treeview items in a wpf application using xaml?
You need to add a custom template for the TreeViewItem like this: <TreeView.Resources> <Style TargetType="{x:Type TreeViewItem}"> <Setter Property="HeaderTemplate"> <Setter.Value> <DataTemplate> <StackPanel Orientation="Horizontal"> <CheckBox Tag="{Binding}" /> <Image Source="{Binding Converter={StaticResource CustomImagePathConvertor}}" /> <TextBlock Text="{Binding}" /> </StackPanel> </DataTemplate> </Setter.Value> </Setter> </Style> </TreeView.Resources>

Categories : Wpf

Displaying Menu items through webview in android application
Found a solution public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.about: startActivity(new Intent(this, About.class)); return true; case R.id.exit: finish(); return true; default: return super.onOptionsItemSelected(item); } and then creating a About.class with these code package com.example.mywebapp; import android.app.Activity; import android.os.Bundle; import android.webkit.WebView; public class About extends Activity { private WebView webView; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.about); webView = (WebView) findViewById(R.id.webView); //webView.getSettings().setJavaScriptEnabled(true

Categories : Android

Why are my custom graphical items constantly repainting in a Qt-based C++ GUI application?
It would seem to me that when calling setScale in paint it connects to setPaintScale, which then calls the QWidget's update function, which then invalidates the area and when it gets back to the main event loop causes a repaint. So you end up getting 1 paint required event every time you call the paint method.

Categories : C++

OS X program to discover application menu items and generate accelerators / hotkeys for them?
A workaround that I have come to is: IJ allows mnemonics via the Option key. Other programs allow most menu items to be reached by typing the first characters of the menu items. These are not at all completely satisfying, but are the best I could find after months of poking at it.

Categories : Objective C

How to Add Items to Selected Listbox1 Items in another Listbox2 items in?
You can use SelectedIndexChanged event private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e) { string curItem = listBox1.SelectedItem.ToString(); //clear and add to listBox2 }

Categories : C#

Architecture/Design of PageObjects for Pages with hierarchy: menu-items/menu-sub-items/menu-sub-items-tabs
I think the following will be a simple and efficient solution, Class for Main page with methods to navigate(or click) other menu items and logout. Class for each menu item with methods for sub menu items, extend the Main page class

Categories : Java

How to mathematically subtract items in two lists in Python and only output those items which meet a condition?
Without using numpy: A = ["40", "60", "80"] B = ["10", "42", "100"] newA = filter(lambda a: all([abs(int(a) - int(b)) >= 5 for b in B]), A) newB = filter(lambda b: all([abs(int(a) - int(b)) >= 5 for a in A]), B) print newA print newB

Categories : Python

What is the appropriate Python data structure to hold its items and a combined list of its items?
I would go for @joel-cornett comment, i.e. consistency in the type of data stored. MATERIALS = [ ['AR'], ['ARU'], ['ARC'], ['CON'], ['CSR'], ['MCR'], ['USF'], ['AR', 'ARU', 'ARC', 'MCR', 'CSR'], ['AR', 'ARU', 'ARC', 'MCR'], ['AR', 'ARU', 'ARC'], ] If this doesn't suit you, then have two lists. And if you know in advance your models, you would preferably use variable than string: AR = 'AR' ARU = 'ARU' ARC = 'ARC' CON = 'CON' CSR = 'CSR' MCR = 'MCR' USF = 'USF' MATERIALS_SIMPLE = [ AR, ARU, ARC, CON, CSR, MCR, USF, ] MATERIALS = [ [AR, ARU, ARC, MCR, CSR], [AR, ARU, ARC, MCR], [AR, ARU, ARC], ] As long as you are not limited in terms of performance, I would tell you not to bother optimizing memory storage

Categories : Python

Hide Items in Context Action Bar (CAB) dynamically when multiple items are selected
As suggested in adneal's comment. Add invalidate() to onItemCHeckedStateChanged() @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { if (checked) { selCount++; idList.add(id); } else { selCount--; idList.remove(id); } mode.setTitle(selCount + " selected"); mode.invalidate(); // Add this to Invalidate CAB } This invalidates the CAB and causes the onPrepareActionMode() function to be called. @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { if (selCount == 1){ MenuItem item = menu.findItem(R.id.edit_item); item.setVisible(true); return true; } else { MenuItem item = menu.findItem(R.id.edit_item); item.set

Categories : Android

Subtract items in a single list and retrieve items that match a condition
Based on your comments, I believe the following list comprehension should do what you are looking for. The key parts are: Using any instead of all to check whether any item exists that is at most 5 smaller or larger than the current one being looked at Using enumerate to ensure the condition ignores the item currently being looked at - you can remove the calls to enumerate and change the comparison to 0 < abs(int(a) - int(b)) <= 5 if you know there are no duplicates Using a list comprehension instead of filter to make it more readable, in my opinion (only just) - it should be possible to do the same thing with filter, however The code: >>> A = ['12', '15', '20', '30'] >>> [a for i, a in enumerate(A) if any(j != i and abs(int(a) - int(b)) <= 5 for j, b in enu

Categories : Python

Extjs 4.1.1 HBox layout not showing all child items or items overlaps
Add flex: 1 to all four of your child items in order to have them size automatically to fill the available width.

Categories : Javascript

How to clear/remove shopping cart items before adding new items in magento?
here is the solution for remove as well as add products into cart $params['qty'] = 1; $product = $this->_initProduct($_product); // here initialize the product $cart = Mage::getModel('checkout/cart'); $cart->truncate(); // remove all active items in cart page $cart->init(); $cart->addProduct($product,$params); $cart->save();

Categories : Magento

jQuery Selector for all items in body excluding items in specific parent
I'm not sure why you'd want to do this, but the following would work (though I imagine it doesn't perform very well as it's filtering everything in the body): var items = $('body').find('*').filter(function() { return !$(this).is('.tooltip') && !$(this).closest('.tooltip').length; }).get(); This will exclude all elements which have the class .tooltip, and all elements which have an ancestor with the class .tooltip, so you'd end up with the following: h1, div.container, h2, p

Categories : Jquery

Is it possible create a list of items ordered in multiple columns, select a column for a maximum of items?
If you are asking about the CSS3 solution, the only way you can do this is using column-count property.. Demo <div class="wrap"> <div>1</div> <div>2</div> <div>3</div> <div>4</div> <div>5</div> <div>6</div> <div>7</div> </div> CSS div.wrap { border: 1px solid #f00; column-count:2; -moz-column-count:2; -webkit-column-count:2; } Note: column-count property is not supported widely yet.. I would suggest you to break the layout programatically. For more info on support, refer this link

Categories : HTML

jQuery Isotype items overlapping onLoad in IE8 - defined width list items, not images
In case anyone stumbles across this tumbleweed question, I ended up having to resolve this using % widths on items as the media query I had was causing the issue. In actual fact, the media query issue only seemed to happen in IE8 so I targetted that browser specifically with styles that used % widths.

Categories : Jquery

Elegant and efficient way to catch events in items inside list view items in Android
Which is the best approach? I don't think there's a best approach. One easy and clean way of implementing what you want is to implement a generic listener for the sub items events and pass those through an interface(implemented by your Activity): public interface OnButtonEventListener { void onSubButtonClicked(int parentRowPosition); } Your activity will implement this interface. Then in the adapter build a generic listener: private OnButtonEventListener mBtnListener; // as you'll pass a Context to your adapter, the Activity which implements the OnButtonEventListener private void OnClickListener mListener = new OnClickListener() { @Override public void onClick(View v) { Integer rowPosition = (Integer) v.getTag();// you could pass other data as well

Categories : Java

Remove multiple items from List view except Selected items
The standard way to do such actions is to use Action mode of action bar. Anyways, Here's an example: DataModel: This exposes data manipulation methods to local code. Here its just using in-memory data structures, but in real applications, it can be backed by a database or a web service or something else. import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Set; public class DataModel { private static DataModel ourInstance = new DataModel(); private final List<String> mPersons; private final HashMap<String,Set<String>> mGroups; public static DataModel getInstance() { return ourInstance; } private DataModel() { mPersons = new ArrayList<String>(); mGroups = new HashMap<S

Categories : Android

how to select 10 random records for 3 items that all 3 items exist in the selection
May not be truly random, but this ensures all three items are present in the result. Is it good enough? SELECT id, store_id, item_id, product_id FROM (SELECT id, store_id, item_id, product_id, ROW_NUMBER () OVER (PARTITION BY store_id ORDER BY r1, DBMS_RANDOM.VALUE) r2 FROM (SELECT id, store_id, item_id, product_id, ROW_NUMBER () OVER (PARTITION BY store_id, product_id ORDER BY DBMS_RANDOM.VALUE) r1 FROM mytab)) WHERE r2 <= 10; Demo at sqlfiddle.

Categories : Oracle

Proper ORDER BY query for items based on associated items in the same table
This should give you the result you want probably This is without using mysql extension to group by and uses a varchar field to group by SELECT b.item_name, Sum(a.sold_count) AS sales FROM products AS a INNER JOIN products AS b ON a.master_id = b.id GROUP BY b.id ORDER BY Sum(a.sold_count) DESC if you want to use the mysql extension and group by an int field SqlFiddle example http://www.sqlfiddle.com/#!2/1725c/4/0

Categories : PHP

Python - identify items from list where sublist items are duplicated
Use a dict here: >>> inputList = [[1, "Data x"], [2, "Data z"], [3, "Data x"]] >>> from collections import defaultdict >>> dic = defaultdict(list) >>> for v, k in inputList: ... dic[k].append(v) ... >>> dic defaultdict(<type 'list'>, {'Data z': [2], 'Data x': [1, 3]}) As the item in your second example are lists, so you need to convert them to tuples first: for v, k in inputList: dic[tuple(k)].append(v)

Categories : Python

How to delete listview items using a button on the list view items
You need remove item in your list which passed from your activity, and then refresh ui. removeLanguageButton.setOnClickListener(new OnClickListener() { public void onClick(View view) { Log.i("langs", "language: " + language); languages.remove(language); notifyDataSetChange(); //here you need to notify the activity list to ensure the data is always right. } });

Categories : Android

Grouping items in Python dictionary, then singling out those items within the groups
data = [ ['GROUP A' , 'DESCRIPTION A' , 'PERSON A' , 1.14], ['GROUP A' , 'DESCRIPTION A', 'PERSON B', 1.14], ['GROUP A' , 'DESCRIPTION A' , 'PERSON C', 0.36], ['GROUP A' , 'DESCRIPTION A' , 'PERSON D', 1.07], ] total_score = sum([x[3] for x in data]) target_person = 'PERSON C' the_score = [ x[3]/total_score for x in data if x[2] == target_person] print(the_score)

Categories : Python

How to control sub menu items in dynamically created contextmenustrip items?
Prior to adding the items, call the Clear() method of your DropDown. You're scanning for folders everytime, so it makes sense to start with a clean slate. Every point in the tree that has sub-items, and to which you add dynamically, is subject to this need to Clear() first.

Categories : C#

How to open dynamic submenu items inside sub-items with jQuery?
You can use the ajax function of jquery to get your subelements dynamically. Then you can append it to your new lists. <li><a href="#">TESTE</a><ul>here you can append your new items</ul></li> Hope it will help you.

Categories : Jquery

How to make full width form items with Bootstrap for all items
Ok, so I think I have solved the problem: http://jsfiddle.net/uAKen/3/ I had to add an additional wrapper areound the form fields. <div class="input-wr"> ... </div>

Categories : CSS

Removing items from an arraylist that contains subclass and superclass items
Absolutely - all you need to do is combining the two approaches that you have: Iterate the list using Iterator the way you do it in the second approach; check for the current item to be a Monster the way you do it in the first approach. This combination would let you find the Monster, and remove it using the iterator. Here is how you can do that: Iterator<Item> iter = items.iterator(); while (iter.hasNext()) { Item item = iter.next(); if (item instanceof Monster) { Monster monster = (Monster)item; if (monster.hasDied()) { if (monster.getLocation() == location) { System.out.println(monster.getDescription() + " has been defeated!"); iter.remove(); } else

Categories : Java

How do I add my shopping cart items to Transaction.item_list_.items
I have figured out that error for anyone else who may run into this here is the code that works Dim pCartItem As PayPal.Api.Payments.Item = New PayPal.Api.Payments.Item orderTransaction.item_list = New PayPal.Api.Payments.ItemList orderTransaction.item_list.items = New List(Of PayPal.Api.Payments.Item) Do While b <= cart.Count - 1 pCartItem.name = cart(b).Name pCartItem.price = cart(b).Price pCartItem.quantity = cart(b).Quantity pCartItem.currency = "USD" pCartItem.sku = cart(b).Sku orderTransaction.item_list.items.Add(pCartItem) pCartItem = New PayPal.Api.Payments.Item b += 1 Loop

Categories : Paypal

Arranging Grid items depending on other items' visibility
It's hard to understand your layout without some diagram or sketch, but I think you can stay with the Grid layout if you set the row height/column width to "auto". This will cause each grid row/column to be large just enough to present its own content. You can also use other layout types such as StackPanel or DockPanel, they give you less control over the positioning of your controls, but provide comfortable automatic layout. EDIT: You can use a WrapPanel to get the expected results: <WrapPanel Orientation="Vertical"> <Label/> <TextBox/> <ComboBox/> </WrapPanel>

Categories : C#

undefined method `items' for nil:NilClass in @cart.items.each
after you redirect to cloths_path from ItemController's create action @cart instance variable will not be available to cloth's controller index action. to need to reset it some how in index action for eg: - you can pass cart id to it and find it in index cloth's action redirect_to clothes_path, card_id: @cart.id and in cloth's index action do @cart = Cart.find params[:cart_id] create a mathod in application controller, and after u create a new cart, save its id in session, like session[:cart] = @cart.id def current_cart @cart = Cart.find session[:cart_id] end and in view use current_cart method instead of @cart

Categories : Ruby On Rails

Handle No Items Found When Getting a List of Items in REST
Depends on how you want to handle the response. I would go for 200 with an empty array, indicating that the REST call succeeded but no matches found. This would be helpful for the layer that consumes the deerialized response. If you are relying heavily on the HTTP status codes for downstream processing/error handling/error messages then 404 is fine. This is helpful if the request is often performed via a browser also. And also this would be a purist approach. I do not see any added value for the third option.

Categories : Api

reading an array with multiple items (working on two items not three)
why don't you check the length of the element before applying your algorithm. using len() for element in filecontent[2]: if len(element) == 3: name, hours, bonus = element ## do other stuff else: name, hours = element EDIT I would suggest if you do not want this solution, you can have the file contents (if you have control over that or you can change it) return always 3 elements where 0 is the default if you have no bonus.

Categories : Python

Randomly choosing items from a list of items
Why not define cells = c(rep('A',3),rep('B',5), rep('C',8), rep('D',6)) and then > cells [1] "A" "A" "A" "B" "B" "B" "B" "B" "C" "C" "C" "C" "C" "C" "C" "C" "D" "D" "D" [20] "D" "D" "D" x <- sample(1:length(cells), ceiling(length(cells)/2)) m1 <- cells[x] [1] "D" "B" "C" "A" "B" "A" "B" "D" "D" "C" "C" m2 <- cells[setdiff(1:length(cells), x)] [1] "A" "B" "B" "C" "C" "C" "C" "C" "D" "D" "D"

Categories : R

Combobox selection items different from display items
If you don't have a particular row visible in the combo list, the combo won't display the text corresponding to the combo's value - no exceptions. However... If you sort the isActive = "N" entries to the bottom, then sort by ID or Code as usual, then the inactive entries won't clutter the list (as much), but will still display correctly. This is most easily done with a query bound to the combo's recordsource. You can also display the isActive column so the users will know what they can and can't select, and prevent selection of isActive = "N" entries in the combo's BeforeUpdate event.

Categories : Ms Access

Moving checked items to the top after unchecking all items
in JS var list = $("ul"); var html=$("ul").html(); sortItems(list); var anch = $('#clear'); list.on('click',"a",function(){ var list = $("ul"); //$(this).parents().eq(0).find(':checkbox').removeAttr('checked'); $("ul").html(html); sortItems(list); }); function sortItems(list){ origOrder = list.children(); list.on("click", ":checkbox", function() { var i, checked = document.createDocumentFragment(), unchecked = document.createDocumentFragment(); for (i = 2; i < origOrder.length; i++) { if (origOrder[i].getElementsByTagName("input")[0].checked) { checked.appendChild(origOrder[i]); } else { unchecked.appendChild(origOrder[i]);

Categories : Javascript

Trying to achieve skewed menu items without skewed text. Came close but 2nd tier items are cascading strangely
Is this what you're wanting to achieve (the positioning of the drop downs may need a bit of tweaking)? http://jsfiddle.net/jzKHD/ The skew on the top level items is also affecting the bounds of the drop down ul -- you're then "unskewing" each drop down li, whereas you should actually unskew the whole ul: ul#nav li ul { /* second-level lists */ border: 1px solid black; position: absolute; width: 200px; left: -999em; /* using left instead of display to hide menus because display: none isnt read by screen readers */ margin: 0px; padding: 0px; /* This transform was moved here from the next rule */ -webkit-transform: skew(25deg); -moz-transform: skew(25deg); -ms-transform: skew(25deg); -o-transform: skew(25deg); transform: s

Categories : Jquery

PHP random value from a possible 5 items with multiple items for each
You could try something like this. Suppose you have an array like you mentioned, with data coming off the DB: red => 100 green => 200 blue => 50 Add the values of all the colors combined (350 in this case). Pick a random value between 1 and that. $randValue = rand(1, 350); Then use a loop to progressively substract the values of the colors until you're left with 0 or a negative: foreach ($colors as $key => $value) { $randValue = $randValue - $value; if ($randValue < 1) { $pickedColor = $key; // and substract 1 from this color in the DB break; } } So, in this case, if $randValue was 124, you would get green.

Categories : PHP

How to perfrom search on array if it has items matching then copy those items in another array in ipad app
- (NSArray *)filteredArrayUsingPredicate:(NSPredicate *)predicate is exactly the function that you want. It will return a new array with only the elements that pass the test in the NSPredicate object. For example: NSArray *newArray = [oldArray filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(Book *evaluatedObject, NSDictionary *bindings) { //Do whatever logic you want to in here return [evaluatedObject.title isEqualToString:theTitle]; }];

Categories : IOS

jQuery replacing list items with different list items with specific classes
You don't have to use .load there, If, classes are already there, you don't have to do anything - Simply remove this Line $(this).load("li a.add-this-list-on-click-instead > *").fadeIn("slow"); and if .add-this-list-on-click-instead are hidden initially - then just make it visible with this - $("#dynamic").click(function() { $this = $(this); var refreshId = setInterval(function() { $('.remove-this-list-on-click').fadeOut("slow", function () { $this.find("a.add-this-list-on-click-instead").fadeIn("slow"); }); }); });

Categories : Jquery

Adding Sharepoint 2010 List Items to a List with external Items
One option is to create an SQL server trigger. This trigger would fire whenever a new sales order is created in your source database. You could make it a CLR trigger, and in the function make use of the SharePoint client interface. After you provided a clearer description of the problem: I believe that you're looking for something like the list event handler. This will run on the events you care about, and you can pull from the database at the appropriate time. Essentially, you need to make a Visual Studio SharePoint project (from my past experience this method requires you to use VS right on the SharePoint server, or else you have to copy a lot of DLLs manually from the server); and make an event receiver.

Categories : SQL



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.