Data comboBox
I have the follwoing:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="addRecord();" width="100%" height="100%">
<mx:Script>
<![CDATA[
import mx.controls.*;
private function addRecord():void{
var vb:VBox = new VBox();
vb.setStyle("backgroundColor", "0xFFFFFF");
var infoLbl:Label = new Label();
infoLbl.text="Information"
infoLbl.setStyle("fontWeight", "bold");
vb.addChild(infoLbl);
var selectCbx:ComboBox = new ComboBox();
selectCbx.prompt = "Make a Selection";
ISSUE 1
selectCbx.dataProvider="{rhdata}";
vb.addChild(selectCbx);
var selectCbx2:ComboBox= new ComboBox();
selectCbx2.prompt = "New/Existing";
ISSUE 2
//// how to add an arraycollection here something like so that it display data in ComboBox
//// <mx:ArrayCollection> <mx:String>New</mx:String> <mx:String>Existing</mx:String> </mx:ArrayCollection>
//// OR can I do something like
//// var RHarray:Array = ["New", "Existing"];
vb.addChild(selectCbx2);
var partA_Lbl:Label = new Label();
partA_Lbl.text = "Part A";
partA_Lbl.setStyle("fontWeight", "bold");
vb.addChild(partA_Lbl);
var recordA_Rte:RichTextEditor = new RichTextEditor();
recordA_Rte.title="Record A"
recordA_Rte.height=249;
recordA_Rte.width=454;
vb.addChild(recordA_Rte);
var recordB_Rte:RichTextEditor = new RichTextEditor();
recordB_Rte.title="Record B"
recordB_Rte.height=249;
recordB_Rte.width=518;
vb.addChild(recordB_Rte);
var partB_Lbl:Label = new Label();
partB_Lbl.text = "Part B";
partB_Lbl.setStyle("fontWeight", "bold");
vb.addChild(partB_Lbl);
var hr:HRule = new HRule();
hr.setStyle("strokeWidth", 2);
hr.setStyle("strokeThickness", 2);
hr.percentWidth = infoVB.width;
infoVB.addChildAt(hr, 0);
infoVB.addChildAt(vb, 0);
]]>
</mx:Script>
[Bindable] public var rhdata:ArrayCollection;
private function resultNR(event:ResultEvent):Void{
rhdata=ArrayCollection(event.result);
<mx:RemoteObject id="cf" destination="ColdFusion" source="cfc.CR">
<mx:method name="getNR" result="resultNR(event)" fault="Alert.show(event.fault.message)"/>
</mx:RemoteObject>
<mx:Button x="878" y="625" label="Add New Record" click="addRecord();"/>
<mx:VBox id="infoVB" verticalGap="15" horizontalAlign="center"/>
</mx:Application>
The issue 1 is when I run this, all I see in the combobox is {rhdata} as result... and nothing else. Please let me know if I'm missing anything.
Thanks...
Hello RosieGp,
See modifications below ... The syntax is a bit different in AS and mxml.
<?xml version="1.0" encoding="utf-8"?><mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"creationComplete="resultNR();addRecord();" width="
100%" height="100%">
<!--creationComplete="addRecord();" width="100%" height="100%">-->
<mx:Script>
<![CDATA[
import mx.controls.*;
import mx.collections.ArrayCollection;
private function addRecord():void {
var vb:VBox = new VBox();vb.setStyle(
"backgroundColor", "0xFFFFFF");
var infoLbl:Label = new Label();infoLbl.text=
"Information" infoLbl.setStyle(
"fontWeight", "bold");vb.addChild(infoLbl);
var selectCbx:ComboBox = new ComboBox();selectCbx.prompt =
"Make a Selection";
//ISSUE 1
//selectCbx.dataProvider="{rhdata}";selectCbx.dataProvider=rhdata;
vb.addChild(selectCbx);
var selectCbx2:ComboBox= new ComboBox();
selectCbx2.prompt =
"New/Existing";
//ISSUE 2
//// how to add an arraycollection here something like so that it display data in ComboBox
//// <mx:ArrayCollection> <mx:String>New</mx:String> <mx:String>Existing</mx:String> </mx:ArrayCollection>
//// OR can I do something like
//// var RHarray:Array = ["New", "Existing"];
var myArrayCollection:ArrayCollection = new ArrayCollection( [{label:'New'},{label:'Existing'}] );selectCbx2.dataProvider = myArrayCollection;
vb.addChild(selectCbx2);
var partA_Lbl:Label = new Label();partA_Lbl.text =
"Part A"; partA_Lbl.setStyle(
"fontWeight", "bold");vb.addChild(partA_Lbl);
var recordA_Rte:RichTextEditor = new RichTextEditor(); recordA_Rte.title=
"Record A"recordA_Rte.height=249;
recordA_Rte.width=454;
vb.addChild(recordA_Rte);
var recordB_Rte:RichTextEditor = new RichTextEditor(); recordB_Rte.title=
"Record B"recordB_Rte.height=249;
recordB_Rte.width=518;
vb.addChild(recordB_Rte);
var partB_Lbl:Label = new Label();partB_Lbl.text =
"Part B"; partB_Lbl.setStyle(
"fontWeight", "bold");vb.addChild(partB_Lbl);
var hr:HRule = new HRule();hr.setStyle(
"strokeWidth", 2);hr.setStyle(
"strokeThickness", 2);hr.percentWidth = infoVB.width;
infoVB.addChildAt(hr, 0);
infoVB.addChildAt(vb, 0);
Bindable]
public var rhdata:ArrayCollection;
/*private function resultNR(event:ResultEvent):void {rhdata=ArrayCollection(event.result);
// I don't have your cfc ...
// Called from creationComplete ...
private function resultNR():void {rhdata =
new ArrayCollection( [{label:'2009-10'},{label:'2010-11'},{label:'2011-12'}] );}
]]>
</mx:Script>
<!--<mx:RemoteObject id="cf" destination="ColdFusion" source="cfc.CR"><mx:method name="getNR" result="resultNR(event)" fault="Alert.show(event.fault.message)"/>
</mx:RemoteObject>-->
<mx:Button x="878" y="625" label="Add New Record" click="addRecord();"/>
<mx:VBox id="infoVB" verticalGap="15" horizontalAlign="center"/>
</mx:Application>
Similar Messages
-
hi guys,
I am developing a hotel reservation system and am stuck..
I need to implement a date combobox (like the one's used when you book flights online) so the user can select day / month and year of reservation.
This is not a web app!!!
I have researched and read through the date and calendar classes but am still a bit stuck.
any one know where i can read and article that might set me on the right path???
your help is appreciated guys!!!
cheersNeither Date nor Calendar are UI widgets. Look here:
http://www.google.com/search?q=jdatechooser -
How to change the data provider of the tree with the selection of combobox
This is my XML data in a file named `nodesAndStuff.xml`.
<?xml version="1.0" encoding="utf-8"?>
<root>
<node label="One" />
<node label="Two" />
<node label="Three" />
<node label="Four" />
<node label="Five" />
<node label="Six" />
<node label="Seven" />
<node label="Eight" />
<node label="Nine" />
</root>
The component using this data source is an `XMLListCollection` which is bound to a spark `ComboBox` and the code for that is:
<s:Application name="Spark_List_dataProvider_XML_test"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo"
initialize="init();">
<fx:Script>
<![CDATA[
private function init():void {
xmlListColl.source = nodes.children();
private function closeHandler(event:Event):void {
myLabel.text = "You selected: " + ComboBox(event.target).selectedItem.label; myData.text = "Data: " + ComboBox(event.target).selectedItem.data;
]]>
</fx:Script>
<fx:Declarations>
<fx:XML id="nodes" source="nodesAndStuff.xml" />
</fx:Declarations>
<mx:ComboBox id="cmbList" dataProvider="{ListXLC}" labelField="STOREVALUE" close="closeHandler(event);"/>
<s:dataProvider>
<s:XMLListCollection id="xmlListColl" />
</s:dataProvider>
</mx:ComboBox>
<mx:VBox width="250" color="0x000000">
<mx:Text width="200" color="blue" text="Select a type of credit card."/>
<mx:Label id="myLabel" text="You selected:"/>
<mx:Label id="myData" text="Data:"/>
</mx:VBox>
<mx:Tree id="myTree" width="50%" height="100%" visible="false" />
</s:Application>
now another of my xml for example this is one.xml
<?xml version="1.0" encoding="utf-8"?>
<root>
<node label="Eleven" />
<node label="Twelve" />
<node label="Thirteen" />
<node label="Fourteen" />
<node label="Fifteen" />
<node label="Sixteen" />
<node label="Seventeen" />
<node label="Eightteen" />
<node label="Nineteen" />
</root>
and another one is two.xml
<?xml version="1.0" encoding="utf-8"?>
<root>
<node label="twety one" />
<node label="twety two" />
<node label="twety three" />
<node label="twety four" />
<node label="twety five" />
<node label="twety six" />
<node label="twety seven" />
<node label="twety eight" />
<node label="twety nine" />
</root>
Now I have added my tree just below the list and I have saved counting from 10 to 19 in `one.xml`, 20 to 29 in `two.xml` and so on in different XML file. I have no clue how to connect the XML containing counting from 10 to 19 as the single node in tree at the selection of label one in list and make its visiblity true.this all are dependent on combobox as on selection of item in combobox will lead to change the dataprovider of tree at runtime. i.e on selecting value one in combobox one.xml should be the data provider for tree control. Can anyone help me on thisThis is my XML data in a file named `nodesAndStuff.xml`.
<?xml version="1.0" encoding="utf-8"?>
<root>
<node label="One" />
<node label="Two" />
<node label="Three" />
<node label="Four" />
<node label="Five" />
<node label="Six" />
<node label="Seven" />
<node label="Eight" />
<node label="Nine" />
</root>
The component using this data source is an `XMLListCollection` which is bound to a spark `ComboBox` and the code for that is:
<s:Application name="Spark_List_dataProvider_XML_test"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo"
initialize="init();">
<fx:Script>
<![CDATA[
private function init():void {
xmlListColl.source = nodes.children();
private function closeHandler(event:Event):void {
myLabel.text = "You selected: " + ComboBox(event.target).selectedItem.label; myData.text = "Data: " + ComboBox(event.target).selectedItem.data;
]]>
</fx:Script>
<fx:Declarations>
<fx:XML id="nodes" source="nodesAndStuff.xml" />
</fx:Declarations>
<mx:ComboBox id="cmbList" dataProvider="{ListXLC}" labelField="STOREVALUE" close="closeHandler(event);"/>
<s:dataProvider>
<s:XMLListCollection id="xmlListColl" />
</s:dataProvider>
</mx:ComboBox>
<mx:VBox width="250" color="0x000000">
<mx:Text width="200" color="blue" text="Select a type of credit card."/>
<mx:Label id="myLabel" text="You selected:"/>
<mx:Label id="myData" text="Data:"/>
</mx:VBox>
<mx:Tree id="myTree" width="50%" height="100%" visible="false" />
</s:Application>
now another of my xml for example this is one.xml
<?xml version="1.0" encoding="utf-8"?>
<root>
<node label="Eleven" />
<node label="Twelve" />
<node label="Thirteen" />
<node label="Fourteen" />
<node label="Fifteen" />
<node label="Sixteen" />
<node label="Seventeen" />
<node label="Eightteen" />
<node label="Nineteen" />
</root>
and another one is two.xml
<?xml version="1.0" encoding="utf-8"?>
<root>
<node label="twety one" />
<node label="twety two" />
<node label="twety three" />
<node label="twety four" />
<node label="twety five" />
<node label="twety six" />
<node label="twety seven" />
<node label="twety eight" />
<node label="twety nine" />
</root>
Now I have added my tree just below the list and I have saved counting from 10 to 19 in `one.xml`, 20 to 29 in `two.xml` and so on in different XML file. I have no clue how to connect the XML containing counting from 10 to 19 as the single node in tree at the selection of label one in list and make its visiblity true.this all are dependent on combobox as on selection of item in combobox will lead to change the dataprovider of tree at runtime. i.e on selecting value one in combobox one.xml should be the data provider for tree control. Can anyone help me on this -
How can I get a combobox to sort different columns of a
datagrid?
For instance the first item in the combobox would sort the
first column in the datagrid and the second item would sort the
second column and so on.
Thanks
Dave"dmschenk" <[email protected]> wrote in
message
news:ggp25g$j39$[email protected]..
> Thanks for your reply. Unfortunately I'm not try trying
to filter the
> data in
> the columns, I just want to sort it.
> In the example in the original post which is derived
from from
>
http://blog.flexexamples.com/2008/04/09/creating-a-custom-sort-on-a-datagrid-con
> trol-in-flex/ .. the buttons do what I am trying to
achieve .... my quest
> is to
> get the combobox to do same thing as the buttons.
> My guess is that the combobox items need to be bound
withe the sortNew and
> sortOld functions but I've been trying for days now
without any luck.
Try something like this:
private function cbCloseHandler(event:Event):void {
myLabel.text = "You selected: " +
ComboBox(event.target).selectedItem.label;
myData.text = "Data: " +
ComboBox(event.target).selectedItem.data;
switch (ComboBox(event.target).selectedItem.label) {
case 'old':
sortOld();
break;
case 'new'"
sortNew();
HTH;
Amy -
Blank values for editable JComboBox
Hello,
I have a editable JComboBox that the user can erase its current value and if they simple change focus (like click on a text field on the same panel) the combo box is left blank. i would like to have it so that if the user leaves focus of the box and its blank that current value goes back to what it was before they erased it.
Many thanks,
Jonathanimport java.awt.FlowLayout;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
public class NonBlankCombo {
JComboBox comboBox;
Object previousContent;
void makeUI() {
Object[] data = {"One", "Two", "Three", "Four", "Five"};
previousContent = data[0];
comboBox = new JComboBox(data);
comboBox.setEditable(true);
comboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED
&& !((String) comboBox.getSelectedItem()).trim().isEmpty()) {
previousContent = comboBox.getSelectedItem();
comboBox.getEditor().getEditorComponent().addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
previousContent = comboBox.getSelectedItem();
public void focusLost(FocusEvent e) {
if (((String)comboBox.getSelectedItem()).trim().isEmpty()) {
comboBox.setSelectedItem(previousContent);
JFrame frame = new JFrame("Non-blank Combo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 100);
frame.setLayout(new FlowLayout());
frame.add(comboBox);
frame.add(new JButton("Click"));
frame.setLocationRelativeTo(null);
frame.setVisible(true);
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new NonBlankCombo().makeUI();
}db -
No success in placing background image in JComboBox drop-down!
Hi All! I have an urgent proble, which I was not able to resolve a full day and a half long!!! I want to place a background image in the dropdown (JPopupMenu) of a JComboBox. Not behind the Menu Items (I know how to do that), but behind the popup itself (the items will have a transparent background). I was surprised to find out that I cannot achieve this via UI delegates (seems paint takes place in JComponent), nor with simply subclassing JPopupMenu (because after I draw the image it is overwritten by a background rectangle). I beleive this is not an easy thing to acheive, but I would accept a complicated solution as well.
Can anyone help me?
Thanks, in advance!Try this for ideas. Change the filename to a valid image file on your machine.import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.SwingUtilities;
import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.plaf.basic.ComboPopup;
import javax.swing.plaf.metal.MetalComboBoxUI;
public class PictureCombo {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new PictureCombo().makeUI();
public void makeUI() {
Object[] data = {"One", "Two", "Three", "Four", "Five"};
JComboBox comboBox = new JComboBox(data);
comboBox.setUI(new PictureComboBoxUI());
comboBox.setRenderer(new PictureListCellRenderer());
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(comboBox);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
class PictureComboBoxUI extends MetalComboBoxUI {
@Override
protected ComboPopup createPopup() {
return new PictureComboPopup(comboBox);
class PictureComboPopup extends BasicComboPopup {
Image image;
public PictureComboPopup(JComboBox comboBox) {
super(comboBox);
try {
image = ImageIO.read(new File("E:/Java/test.jpg"));
} catch (IOException ex) {
ex.printStackTrace();
@Override
protected JList createList() {
JList retVal = new JList(comboBox.getModel()) {
@Override
public void processMouseEvent(MouseEvent e) {
if (e.isControlDown()) {
e = new MouseEvent((Component) e.getSource(), e.getID(), e.
getWhen(),
e.getModifiers() ^ InputEvent.CTRL_MASK,
e.getX(), e.getY(),
e.getXOnScreen(), e.getYOnScreen(),
e.getClickCount(),
e.isPopupTrigger(),
MouseEvent.NOBUTTON);
super.processMouseEvent(e);
@Override
protected void paintComponent(Graphics g) {
if (image != null) {
g.drawImage(image, 0, 0, comboBox);
super.paintComponent(g);
retVal.setOpaque(false);
return retVal;
class PictureListCellRenderer extends DefaultListCellRenderer {
@Override
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected,
cellHasFocus);
Color selBgColor = list.getSelectionBackground();
selBgColor = new Color(selBgColor.getRGB() & 0xA0FFFFFF, true);
setBackground(selBgColor);
setOpaque(isSelected);
return this;
}db -
How to refrash tabbed pane at a run time
hi,
I have no practice in using tabbed panes, and now I have to solve a little problem. I am running internal frame wich contains tabbedpane. The tab which opens by default contains combobox which reads its data from DB. But when I open internal frame no data exists in a combobox.
Since I change the tab and select back again the same tab data combobox reads its data. I tried to validate the tab but nothing changes.
Where is my fault?The code that loads the data into the combo box is not being executed when you first create the internal frame. We can't tell you why since we have no idea what your code looks like.
So, trace the order of execution to see why the code is not executing. -
Getting data in a combobox from database
I have done database connectivity in flex using .net. Now I am getting data in flex in a data grid. Everuthing is working fine if I take data in a data grid.
My problem is that if I try to take that data in any other control, other than data grid, it shows up no data, it only shows "object[object].
for ex:
if I am getting 3 rows from databse and I try to get those in a combo box, den I am getting 3 items in combo box like this:
object[object]
object[object]
object[object]
instead of actual data.
I am stuck in this problem for last 3 days. I have tried lot of things but nuthing is working. Plz anyone help me out soon. Its really urgent.
I am working on a live project and not able to proceed because of this problem.Hi Bhavika,
You need to tell your combobox which value should be displayed in the ComboBox...for display...
You are getting 3 rows from database which are objects since you haven't told your combobox which value to be displayed it is displaying as [Object,Object]...
So you need to tell your ComboBox which values to be displayed ..and you can do this by assigning the labelField property of the ComboBox..
Say in your object you have three properties say..data, value, name...etc;;
Then if you want display name as your ComboBox display label then simply write ....labelField="name" in your ComboBox ...
Thanks,
Bhasker Chari -
Date Changes by itself in ComboBox
Hi Gurus,
I am opening this thread in continuation to my previous thread:-
Date range in Xcelsius
I could resolve this issue by referencing the cells in the next column in descending order for eg. I had data in ascending order in M3 to M38 so what I did was in N3 to N38 i referenced as follows In N3 I referenced M38, in N4 I referenced M37, In N5 M36 is referenced..Like that. And referenced all the combo boxes to N3:N38. And it helped me to get the desired results. However, I am facing a very strange problem.
In the Dashboard comboBox, if we select 08/2010, after 10 seconds it goes back to 7/2008. I have checked all the propertied and did not find anything which could cause this problem.
Anyone has any idea why its happening?
Regardsresolved
-
Hi all,
I'm very new to VBA and excel development, so please take that into consideration as you read on.
I'm trying to create a work form for a database that (should) collect various information in comboboxes, including the date, the weekday, and the month... Note: most of the time, the data will be inserted the day after it's been collected. So, I wanted to create
one combobox for the date, one for the weekday, and one for the month, because I want columns for each of these in the database (If this is not necessary/efficient, please help! :) ) .
Here's what I've got so far:
'worksheet setup
Dim ws As Worksheet
Set ws = Worksheets("LookupList")
'Date dropdown setup
Dim cDateToday As Range
For Each cDateToday In ws.Range("DateList")
With Me.cboDate
.AddItem cDateToday.Value
End With
Next cDateToday
'If today is Monday, then set date to last friday, if any other weekday, set it to day before that
If Weekday(Date - 1) <> 2 Then
Me.cboDate.Value = Format(DateAdd("D", -Weekday(Date) - 1, Date), "Medium Date")
Else
Me.cboDate.Value = Format(Date - 1, "Medium Date")
End If
Problem #1: Right now, I am getting the date values from the list
DateList in the worksheet LookupList...is there a better way of doing this?
Problem #2: When the user form is run, the correct date and format shows up. However, if I change the date, the dropdown list in the combobox starts from the initial date in given list...is there anyway to bring the list closer to the current
date? Think Calendar View
Problem #3: I want the weekday and month values to be directly correlated to the date value discussed above, so hypothetically when the user form is run the correct date, weekday, and month all show up (based on the same date value), then if
I change the date, the weekday and month automatically update. Is this possible, if so how?
The reason I want this functionality is so that on a Monday, I can run the work form and it will automatically have Friday's date, weekday, month info as it opens. When I'm done with Friday, I can run it again, switch the date to the Saturday's
date (weekday and month automatically update), then repeat for Sunday.
I have tried running the same code for the weekday and month as I have for the date, and they work
until the date is changed. Once the date is changed, I have to manually change the weekday, which leads to format change, and same for month, which all leads to :( and confusion
Again, I am very new to vba and don't know much about it all and appreciate any/all help!
Thanks in advance!
/AlexI can give you a little advice but I don't understand your comment "if I change the date, the weekday and month automatically update" Where do you want them to update?
I am assuming that your entire question is referring to a Userform with the Combobox. Is this correct?
The code can be much simpler to populate the combobox list. You already have a named range for the Dates so you can use that directly to populate the RowSource. (RowSource if the combox is on a Userform or ListFillRange for a combobox on a worksheet).
Then the WorksheetFunction Workday can be used to get the previous workday without weekend days. It also looks after the previous day when the actual date is mid week. Look up the function on the worksheet Help because you can also have a separate list
of holidays that will be excluded like weekend days.
If you are new to VBA then a tip about Help. You need to be on the worksheet and click Help to get worksheet help and in the VBA editor you click Help to call the VBA help. Don't just select Help off the taskbar when changing between the worksheet and VBA
because you will finish up with the incorrect Help file.
Example of code to assign a named range to the RowSource of a ComboBox. Named range needs to be Global and not scoped to a worksheet otherwise the worksheet name is also required.
Me.cboDate.RowSource = "DateList"
Example of code to assign the previous workday to the combobox value.
'Following line sets value to previous workday (Mon to Friday)
Me.cboDate.Value = WorksheetFunction.WorkDay(Date, -1)
Then there is another problem with ComboBoxes and dates. If the Dates are real dates on the worksheet (Not Text) then the dropdown list displays in the same format as the worksheet but when the date is selected, it displays as a serial number. This
can also be rectified with code but first I need to know what the format of the data is on the worksheet.
Can you upload a copy of your workbook because it is like a picture is worth a thousand words. Same goes for having a copy of the workbook. If it has sensitive data then create a copy and remove the sensitive data.
Regards, OssieMac -
How to send a data from combobox to list box in java when I click datas
ow to send a data from combobox to list box in java when I click datas in combobox
use getItemAt() from combo and add them to list model.
-
How to add the data to combobox
how to add data directly into
info swing component jcomboboxcontrol in jdevloper.
can any one help.
thanks
sweety<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by pullareddyj:
u just addlike following method for insert
data in combobox.
"comboBoxControl1.addItem("jan");"
pullareddy<HR></BLOCKQUOTE>
THANKS
SWEETY -
How to sort data from database and display in combobox in required order
Hi evrybody, it makes me sick i need to get data form database and fill combobox in required order (last item added to database - last firstName) actualy i already did that, but i'm useing DefaultComboBoxModel and all records are sorted in alphabetical order. Thanks very much for any help
The items in the JComboBox are displayed in the order in which you add them to the combo box. Use an order by clause in your SQL statement.
Don't [url http://forum.java.sun.com/thread.jsp?forum=54&thread=516608]crosspost. -
Fxml ComboBox created in scene builder how to fetch data from database
Hi Sir, How r u? Hope to be fine. Sir, I have a problem that i want to fetch data in fxml comboBox created in Scene Builder?
I have used this code in JavaFx 2.0 for comboBox and textField the code is
ComboBox studentRegId = new ComboBox();
try{
stm = db.con.createStatement();
rs = stm.executeQuery("select * from students order by s_reg_id asc");
while(rs.next()){
for(int i=1; i<=1; i++)
studentRegId.getItems().add(rs.getString("s_reg_id"));
}catch(SQLException sqlException){
final TextField sRegId = new TextField();
final String regId[] = new String[1000];
try{
stm = db.con.createStatement();
rs = stm.executeQuery("select * from students order by s_reg_id asc");
int a = 0;
while(rs.next()) {
regId[a] = rs.getString("s_reg_id");
a++; }
}catch(SQLException sqlException){
studentRegId.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>(){
public void changed(ObservableValue ov,Number value, Number new_value){
sRegId.setText(regId[new_value.intValue()]);
Now, the problem is that I want to use this code in Scene Builder fxml ComboBox .
Please Help Me!
I shall be very grate full to you for this kindness.
RegardsHi,
Ok, so you create your FXML :
Add a controller property to your root control. (See Code tab in SceneBuilder or direcly in FXML : fx:controller tag)
Add a fx:id to your controls (your combobox) (First property in SceneBuilder or directly in FXML : fx:id)
Example :
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.collections.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>
<HBox prefHeight="-1.0" prefWidth="-1.0" xmlns:fx="http://javafx.com/fxml" fx:controller="org.lgringo.comboexample.Controler">
<children>
<TextField fx:id="text" prefWidth="100.0" />
<ComboBox fx:id="combo" prefWidth="200.0">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="Item 1" />
<String fx:value="Item 2" />
<String fx:value="Item 3" />
</FXCollections>
</items>
</ComboBox>
</children>
</HBox>Then, you create your Controler class using @FXML annotation (name of control should be the name of fx:id properties)
You can do some initialisation in the inherit method "initialize"
Example :
package org.lgringo.comboexample;
import javafx.fxml.FXML;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
public class Controler {
@FXML
// fx:id="combo"
private ComboBox<String> combo; // Value injected by FXMLLoader
@FXML
// fx:id="text"
private TextField text; // Value injected by FXMLLoader
@FXML // This method is called by the FXMLLoader when initialization is complete
void initialize() {
assert combo != null : "fx:id=\"combo\" was not injected: check your FXML file 'ComboboxExample.fxml'.";
assert text != null : "fx:id=\"text\" was not injected: check your FXML file 'ComboboxExample.fxml'.";
// Initialize your logic here: all @FXML variables will have been injected
combo.getItems().clear();
combo.getItems().addAll("John Lennon","Mick Jagger","David Bowie");
combo.getItems().add("Others...");
text.setText("List : ");
}Then you use the FXMLLoader class to load your FXML and Controler.
Example :
package org.lgringo.comboexample;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class App extends Application {
* @param args
public static void main(String[] args) {
App.launch(args);
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("ComboboxExample.fxml"));
primaryStage.setTitle("Combo Example");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}More info : http://docs.oracle.com/javafx/2/get_started/fxml_tutorial.htm -
Loading a combobox with data from a different domain
I have filled in a combobox with values from an .asp page and
have used it
successfully. The problem is that if the flash file is ran
from a different
domain from the load location, the combobox doesn't get
filled in (as
apposed to the error if I ran it off of my drive).
datafeed.asp spits out the appropriate stuff for the AddItems
function to
read correctly. (as I has said, it does work). The combobox
gets filled in
the development environment (Macromedia Flash MX Professional
2004) as well
as flash player.
But when I upload it to one of my other websites, the data is
never
retrieved. Even though that the webserver containing the data
feed, the
webserver hosting the flash file and my machine can all read
datafeed.asp.
Am I missing a setting that allows a flash file to read data
from another
domain?
The following code has been changed for security reasons. But
believe me it
works in its original format.
myData = new LoadVars();
myData.onLoad = AddItems;
myData.load("
http://www.mydomain.com/datafeed.asp")
function AddItems() {
for (i=0; i<numItems; i++) {
var ProductID = eval("myData.ProductID"+i);
var ProductName = eval("myData.ProductName"+i);
var ProductSale = eval("myData.ProductSale"+i);
var DataProvider = { productid
roductID, productsale
roductSale };
_root.application.chooseproducts.prodlist_cb.addItem(ProductName,
DataProvider);
Thank You,
Juliannot sure, but this might be what you need...
//allow loading of files from domain
System.security.allowDomain("
http://www.mydomain.com");
Maybe you are looking for
-
Corrupted. Now what?
My 160GB Classic is corrupted (error 1439). I've reset it to factory settings. When I connect to iTunes, it won't connect. The device doesn't show up in iTunes. I've made sure to download the most recent version of iTunes, and restarted my computer,
-
Illustrator CS5.5 Transforms in Actions not working properly?
I'm doing a simple transform action. I want to move an object to a value on the Y axis. First of all, after recording the action, and setting the Y value to 64 px, the action is recorded as 64 pt, not px. This happens regardless of my 'Units' setting
-
Cannot open kernel menu configuration
In both architectures, when I go to /usr/src/linux and enter a: make menuconfig This is what I get: scripts/kconfig/mconf arch/i386/Kconfig drivers/crypto/Kconfig:44: can't open file "arch/s390/crypto/Kconfig" make[1]: *** [menuconfig] Error 1 make:
-
Skype for Business - Cannot see shared screens, but I can share my screen
I just started a new job and am required to use Skype for Business. I downloaded Skype for Business 32 bit. My PC is 64 bit but because I already have other Office 32 bit programs, I cannot install the 64 bit version. Everything in Skype for Busine
-
ITunes will not let me purchase a song...what now?
I am trying to buy a song. I click "Buy" and it takes me to the page where I read the terms of agreement. I check the box that says I've read the terms. I then check "continue" but then I get an error message saying "Session Timeout...Your session ha