What i need to do is let the user restore the default itemRenderer after they put in a custom one.
It works for List, but not when i try to do it for combobox and dropdownList. When i try open the combobox with a resetted defaultItemRenderer then the items are not shown (but i can still select items with the arrow keys).
This is how i do it:
defaultItemRenderer = component.itemRenderer;
component.itemRenderer = new ClassFactory(MyListItemRenderer);
...some time later when the user says it...
component.itemRenderer = defaultItemRenderer;
component.validateNow();
As i said, for List it works like a charm, but not for combobox.
P.S. im refering to spark components
Related
I've got a form that contains a toggle button. To set the state of the togglebutton I use the property 'ToggleState' (which can be true or false).
I want to set the toggle button via databinding. I've pulled some data from a database and placed this in a listbox.
When selecting a item from the listbox all the other fields are populated with the corresponding data.
The only thing that's not set correctly is the toggle button.
Here is the code I have used to set the buttonstate via databinding. The buttonstate does not work.
ToggleButton1.DataBindings.Add("ToggleState", table, "Goedgekeurd", True, DataSourceUpdateMode.OnPropertyChanged)
If I use the code below the buttonstate will set correctly.
ToggleButton1.ToggleState = 1
Can someone help me out what the difference is between the two?
I'm quite new to VBA and I've been looking around but cannot seem to find a solution to my problem.
I have made a navigation form (frmNavigation) with 3 buttons, each referring to a different form, let's call them frm1, frm2 and frm3. In the navigationform the control buttons to switch between tabs are all named differently (btn1, btn2, btn3), but the subform that shows either frm1, frm2, or frm3 has the same name: “NavigationSubform” (this shows a different form depending on which tab is clicked on, based on the 'navagation target name' referring to frm1, frm2 and frm3).
When I want to refer to a textbox (txtBox1) on form 1 (first tab) and insert a value i can do this by:
Forms!frmNavigation!NavigationSubform.Form!txtBox1.Value = "insert awesome text"
But how would I refer to txtbox10 on the second tab (frm2)? Just using the following does not work:
Forms!frmNavigation!NavigationSubform.Form!txtBox10.Value
You then get the error 2465 (can't find the field).
I’ve been trying many different things, but can’t seem to get it right. So how do I refer to a textbox on a different tab than the first one?
Help us much appreciated!
Only one subform can be loaded at once. So you've just got to break this process into two steps.
Store the value from txtBox1 somewhere outside of the NavigationSubforms (a textbox on the parent form with visible = no, a global variable or a table works).
In frm2's On Load event, set txtbox10 to be the value you stored.
Just note, that you will need to add conditions in the On Load event if you want to avoid that textbox being set to an empty string or a wrong value if you have a setup where your filter is changing.
I want to automate DropDownList when DropDownList id and item index are provided.
I can get DropDownList object on that object I can set selectedIndex as
dropDownObject.selectedIndex=index;
this can change DropDownList selected item to specified index item but when I dispatch "change" event on IndexChangeEvent object it is giving typeCoersion error.
can not convert spark.events::IndexChangeEvent#138445 to spark.events.IndexChangeEvent
Based on your question, I am assuming you want to catch the change in the selection of the drop down list.
Do not dispatch the change event, instead, you should listen for the valueCommit event and not the change event in this case. The valueCommit event is designed to fire when the selected index is changed both programmatically or by user interaction.
Taken right from the docs:
valueCommit
Dispatched when values are changed programmatically or by user
interaction.
So, do something like this:
<s:DropDownList valueCommit="changeHandler(event)" dataProvider="{yourData}" id="dropDown"/>
Hope this helps.
I solved this problem by setting
dropDownListObject.selectedIndex = providedIndex
after calling
dropDownListObject.closeDropDown(true)
so far I did this and solved problem
dropDownListObject.openDropDown();
dropDownListObject.selectedIndex = providedIndex;
dropDownListObject.closeDropDown(true);
dropDownListObject.selectedIndex = providedIndex;
I was missing last line, which was resulting to set selectedIndex to default one.
Currently I am using UiService to create a form and I uses ListBox, from what I understand to pass a value via handler will be something like e.parameter.[Name of ListBox] to access the selected item.
Does anyone know is it possible to use like app.getElementById([Name of ListBox]) to access the selected item. The reason I am using this method is because my list of ListBox-es are dynamic.
I spent some time looking for this answer as well, but finally I tried one idea and it worked.
You can use e.parameter as an array so you can these two will give the same:
e.parameter.LIST_BOX_NAME
and
e.parameter['LIST_BOX_NAME']
So in the second sample any dynamic list box ID can be used. I use same handler for all added dropdown list and have this code to check what dropdown was changed and what value it has now:
if (e.parameter[e.parameter.source] == 'a'){
To change the content of the listBox you can use app.getElementById('ID of the listBox'), from there you can clear() and addItems again but you cannot read the listItems.
When I need to do this I usually store the list of items somewhere else, in a place that I can read anytime, for example the list of items can be stored as a string in the listBox tag itself so I have all items at hand to repopulate the listBox after I have clear it.
I am using NETBEANS 7 . I have on JList in my project. Here is my code
private void dateChooserSelectedDatePropertyChange(java.beans.PropertyChangeEvent evt) {
DefaultListModel model = new DefaultListModel();
listSerialNo = new JList(model);
UpdatePurchase updatePurchase = new UpdatePurchase();
Vector<String> serialNo = new Vector<String>();
serialNo = updatePurchase.getSerialNo(date);
if(serialNo.size()>0){
listSerialNo.setListData(serialNo);
}
else{
model.clear();
this.resetFields();
}
}
If I write above code then list doesn't show any thing & its not clearing the JList. But If I remove
DefaultListModel model = new DefaultListModel();
listSerialNo = new JList(model);
then list populates with some data from vector serialNo.
My problem:
I want to clear the contents of list if date value changed & no records are present for selected date.
Also I want to clear the contents of list when I click "Reset" button on my form.
Basically I can not clear the contents of jList. Please guide me. Thanks.
Try this-
listSerialNo.setListData(new Vector());
This will re-set the list data with a empty vector object.
so all the list data will be removed.
You probably already have an JList component added which is visible. In your code you create a new one while overriding the field containing the old one. Therefore you lost the 'connection' to the old (and visible) one. By updating the new one nothing visible will change as you update the wrong one.
By removing those 2 lines, you are not creating a new JList anymore and are updating the correct one.
So why not just remove those 2 lines as that seems to work according to your post.
The method setListData actually replaces the data model of your JList. Thus you do not clear the current list model but the initially assigned (which is no longer under use). Therefore, do not use setListData but add the new elements directly to your original model.