Width of combo box
Hi
Access 2013.
I have two columns in the combo box drop down (image below) and I need the drop down part to be wider than the combobox editor to fit the two columns. How do I achieve this please?
Thanks
Regards
There are three things that need adjusting.
First, it looks like you are doing this in the Table. The Table doesn't matter as you don't really use that for data entry or data viewing anyway. If this is on a Form or Table the method is about the same as follows.
Switch to design view of the Form.
Display the property sheet.
On the Format Tab, adjust the Column Widths to the desired amount ie. 0";1";1" (example of three columns with the first being hidden)
Change the List Width to a little larger than the visible width added together above ie 0 + 1 + 1 = 2 so 2.05" should cover it but you can play with it to your satisfaction.
Width should be set to accommodate the above also.
Hth
2015 04 29 4:46 PM Add # 5
Just takes a click to give thanks for a helpful post or answer.
Please vote “Helpful” or Mark as “Answer” as appropriate.
Chris Ward
Microsoft Community Contributor 2012
Similar Messages
-
Combo box popup width adjusting no longer work in 1.0.6_26-b03
Previously, I was able to adjusting combo box popup's width, by referring to the technique described in [http://tips4java.wordpress.com/2010/11/28/combo-box-popup/|http://tips4java.wordpress.com/2010/11/28/combo-box-popup/]. During that time, I was using 1.0.6_24-b07.
However, after I update my Java runtime to 1.0.6_26-b03, things broke.
Here is the screen shoot.
[Workable screen shoot|http://i.imgur.com/0elo7.png]
[Not workable screen shoot|http://i.imgur.com/BeKMy.png]
Here is the code snippet to demonstrate this problem.
* To change this template, choose Tools | Templates
* and open the template in the editor.
* NewJFrame.java
* Created on Aug 9, 2011, 4:13:41 AM
package experiment;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import javax.swing.JComboBox;
import javax.swing.JList;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.plaf.basic.BasicComboPopup;
* @author yccheok
public class NewJFrame extends javax.swing.JFrame {
* Adjust popup for combo box, so that horizontal scrollbar will not display.
* Resize JComboBox dropdown doesn't work without customized ListCellRenderer
* http://www.camick.com/java/source/BoundsPopupMenuListener.java
* @param comboBox The combo box
public static void adjustPopupWidth(JComboBox comboBox) {
if (comboBox.getItemCount() == 0) return;
Object comp = comboBox.getAccessibleContext().getAccessibleChild(0);
if (!(comp instanceof BasicComboPopup)) {
return;
BasicComboPopup popup = (BasicComboPopup)comp;
JList list = popup.getList();
JScrollPane scrollPane = getScrollPane(popup);
// Just to be paranoid enough.
if (list == null || scrollPane == null) {
return;
// Determine the maximimum width to use:
// a) determine the popup preferred width
// b) ensure width is not less than the scroll pane width
int popupWidth = list.getPreferredSize().width
+ 5 // make sure horizontal scrollbar doesn't appear
+ getScrollBarWidth(popup, scrollPane);
Dimension scrollPaneSize = scrollPane.getPreferredSize();
popupWidth = Math.max(popupWidth, scrollPaneSize.width);
// Adjust the width
scrollPaneSize.width = popupWidth;
scrollPane.setPreferredSize(scrollPaneSize);
scrollPane.setMaximumSize(scrollPaneSize);
* I can't find any property on the scrollBar to determine if it will be
* displayed or not so use brute force to determine this.
private static int getScrollBarWidth(BasicComboPopup popup, JScrollPane scrollPane) {
int scrollBarWidth = 0;
Component component = popup.getInvoker();
if (component instanceof JComboBox) {
JComboBox comboBox = (JComboBox)component;
if (comboBox.getItemCount() > comboBox.getMaximumRowCount()) {
JScrollBar vertical = scrollPane.getVerticalScrollBar();
scrollBarWidth = vertical.getPreferredSize().width;
return scrollBarWidth;
* Get the scroll pane used by the popup so its bounds can be adjusted
private static JScrollPane getScrollPane(BasicComboPopup popup) {
JList list = popup.getList();
Container c = SwingUtilities.getAncestorOfClass(JScrollPane.class, list);
return (JScrollPane)c;
/** Creates new form NewJFrame */
public NewJFrame() {
initComponents();
this.jComboBox1.addPopupMenuListener(getPopupMenuListener());
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jComboBox1 = new javax.swing.JComboBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4", "This is a very long text. This is a very long text" }));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(82, 82, 82)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(242, Short.MAX_VALUE))
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(34, 34, 34)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(246, Short.MAX_VALUE))
pack();
}// </editor-fold>
* @param args the command line arguments
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
private PopupMenuListener getPopupMenuListener() {
return new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
// We will have a much wider drop down list.
adjustPopupWidth(jComboBox1);
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
// Variables declaration - do not modify
private javax.swing.JComboBox jComboBox1;
// End of variables declaration
}I had came across another workaround as stated here.
[http://www.jroller.com/santhosh/entry/make_jcombobox_popup_wide_enough|http://www.jroller.com/santhosh/entry/make_jcombobox_popup_wide_enough]
The popup's is having enough width to show all items. However, it is not perfect still, as the width is little too much. I still can see some extra space at the tailing of the list.
The workaround is as follow.
import javax.swing.*;
import java.awt.*;
import java.util.Vector;
// got this workaround from the following bug:
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4618607
public class WideComboBox extends JComboBox{
public WideComboBox() {
public WideComboBox(final Object items[]){
super(items);
public WideComboBox(Vector items) {
super(items);
public WideComboBox(ComboBoxModel aModel) {
super(aModel);
private boolean layingOut = false;
public void doLayout(){
try{
layingOut = true;
super.doLayout();
}finally{
layingOut = false;
public Dimension getSize(){
Dimension dim = super.getSize();
if(!layingOut)
dim.width = Math.max(dim.width, getPreferredSize().width);
return dim;
} -
Determine the best width for ListCellRenderer - Multi-column combo box
Currently, I am having a multi column combo box. In order for the column to align properly during show popup, I use box layout to do so. However, the short coming for box layout is that, the size for each column is fixed. This makes me have a difficulty, when I have a long string to be displayed. The problem is shown through the following screen shoot.
http://i.imgur.com/4Nfc6.png
This is because in 2nd column,
1) All the 3 rows must be in same size so that they are aligned.
2) But 1st row and 2nd row cell renderer, do not know 3rd row is holding such a long string.
The code (2 files) to demo this problem is as follow. Is there any way the size of the cell will be adjusted automatically? Yet, all the row will be aligned properly.
ResultSetCellRenderer.java
package javaapplication24;
import java.awt.Color;
import java.awt.Component;
import javaapplication24.NewJFrame.ResultType;
import javax.swing.JList;
import javax.swing.ListCellRenderer;
import javax.swing.UIManager;
* @author yccheok
public class ResultSetCellRenderer extends javax.swing.JPanel implements ListCellRenderer {
/** Creates new form ResultSetCellRenderer */
public ResultSetCellRenderer() {
initComponents();
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.X_AXIS));
jLabel1.setText("jLabel1");
jLabel1.setMaximumSize(new java.awt.Dimension(88, 14));
jLabel1.setMinimumSize(new java.awt.Dimension(88, 14));
jLabel1.setPreferredSize(new java.awt.Dimension(88, 14));
add(jLabel1);
jLabel2.setText("jLabel2");
jLabel2.setMaximumSize(new java.awt.Dimension(100, 14));
jLabel2.setMinimumSize(new java.awt.Dimension(200, 14));
jLabel2.setPreferredSize(new java.awt.Dimension(100, 14));
add(jLabel2);
}// </editor-fold>
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
// End of variables declaration
// Do not use static, so that our on-the-fly look n feel change will work.
private final Color cfc = UIManager.getColor("ComboBox.foreground");
private final Color cbc = UIManager.getColor("ComboBox.background");
private final Color csfc = UIManager.getColor("ComboBox.selectionForeground");
private final Color csbc = UIManager.getColor("ComboBox.selectionBackground");
private final Color cdfc = UIManager.getColor("ComboBox.disabledForeground");
// For Nimbus look n feel.
private final Color nimbus_csfc;
Color c = UIManager.getColor("ComboBox:\"ComboBox.renderer\"[Selected].textForeground");
// Pretty interesting. Applying "c" directly on the component will not
// work. I have the create a new instance of Color based on "c" to make
// it works.
nimbus_csfc = c != null ? new Color(c.getRed(), c.getGreen(), c.getBlue()) : null;
private final Color nimbus_csbc;
Color c = UIManager.getColor("ComboBox:\"ComboBox.renderer\"[Selected].background");
// Pretty interesting. Applying "c" directly on the component will not
// work. I have the create a new instance of Color based on "c" to make
// it works.
nimbus_csbc = c != null ? new Color(c.getRed(), c.getGreen(), c.getBlue()) : null;
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
final Color _csbc = csbc != null ? csbc : nimbus_csbc;
final Color _csfc = csfc != null ? csfc : nimbus_csfc;
this.setBackground(isSelected ? _csbc : cbc);
this.setForeground(isSelected ? _csfc : cfc);
jLabel1.setBackground(isSelected ? _csbc : cbc);
jLabel1.setForeground(isSelected ? _csfc : cfc);
jLabel2.setBackground(isSelected ? _csbc : cbc);
jLabel2.setForeground(isSelected ? _csfc : cfc);
final ResultType result = (ResultType)value;
jLabel1.setText(result.symbol);
jLabel2.setText(result.name);
return this;
NewJFrame.java
package javaapplication24;
import java.awt.Container;
import java.awt.Dimension;
import javax.swing.JComboBox;
import javax.swing.JList;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.plaf.basic.BasicComboPopup;
* @author yccheok
public class NewJFrame extends javax.swing.JFrame {
public static class ResultType {
* The symbol.
public final String symbol;
* The name.
public final String name;
public ResultType(String symbol, String name) {
this.symbol = symbol;
this.name = name;
@Override
public String toString() {
return symbol;
/** Creates new form NewJFrame */
public NewJFrame() {
initComponents();
this.jComboBox1.addPopupMenuListener(this.getPopupMenuListener());
this.jComboBox1.setRenderer(new ResultSetCellRenderer());
this.jComboBox1.addItem(new ResultType("Number 1", "Normal"));
this.jComboBox1.addItem(new ResultType("Number 2", "Normal"));
this.jComboBox1.addItem(new ResultType("Number 3", "A VERY VERY VERY VERY long text"));
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jComboBox1 = new javax.swing.JComboBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jComboBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1ActionPerformed(evt);
getContentPane().add(jComboBox1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 110, -1));
pack();
}// </editor-fold>
private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
* @param args the command line arguments
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
final NewJFrame frame = new NewJFrame();
frame.setVisible(true);
private PopupMenuListener getPopupMenuListener() {
return new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
// We will have a much wider drop down list.
adjustPopupWidth(jComboBox1);
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
* Adjust popup for combo box, so that horizontal scrollbar will not display.
* Resize JComboBox dropdown doesn't work without customized ListCellRenderer
* http://www.camick.com/java/source/BoundsPopupMenuListener.java
* @param comboBox The combo box
public static void adjustPopupWidth(JComboBox comboBox) {
if (comboBox.getItemCount() == 0) return;
Object comp = comboBox.getAccessibleContext().getAccessibleChild(0);
if (!(comp instanceof BasicComboPopup)) {
return;
BasicComboPopup popup = (BasicComboPopup)comp;
JList list = popup.getList();
JScrollPane scrollPane = getScrollPane(popup);
// Just to be paranoid enough.
if (list == null || scrollPane == null) {
return;
// Determine the maximimum width to use:
// a) determine the popup preferred width
// b) ensure width is not less than the scroll pane width
int popupWidth = list.getPreferredSize().width
+ 5 // make sure horizontal scrollbar doesn't appear
+ getScrollBarWidth(popup, scrollPane);
Dimension scrollPaneSize = scrollPane.getPreferredSize();
popupWidth = Math.max(popupWidth, scrollPaneSize.width);
// Adjust the width
scrollPaneSize.width = popupWidth;
scrollPane.setPreferredSize(scrollPaneSize);
scrollPane.setMaximumSize(scrollPaneSize);
* I can't find any property on the scrollBar to determine if it will be
* displayed or not so use brute force to determine this.
private static int getScrollBarWidth(BasicComboPopup popup, JScrollPane scrollPane) {
int scrollBarWidth = 0;
JComboBox comboBox = (JComboBox)popup.getInvoker();
if (comboBox.getItemCount() > comboBox.getMaximumRowCount()) {
JScrollBar vertical = scrollPane.getVerticalScrollBar();
scrollBarWidth = vertical.getPreferredSize().width;
return scrollBarWidth;
* Get the scroll pane used by the popup so its bounds can be adjusted
private static JScrollPane getScrollPane(BasicComboPopup popup) {
JList list = popup.getList();
Container c = SwingUtilities.getAncestorOfClass(JScrollPane.class, list);
return (JScrollPane)c;
// Variables declaration - do not modify
private javax.swing.JComboBox jComboBox1;
// End of variables declaration
}Edited by: yccheok on Jan 13, 2011 9:35 AMAre these two lines intentionally or is it just a mismatch?
jLabel2.setMaximumSize(new java.awt.Dimension(100, 14));
jLabel2.setMinimumSize(new java.awt.Dimension(200, 14));
2) But 1st row and 2nd row cell renderer, do not know 3rd row is holding such a long string.There is only one cell renderer for all rows, so no need for the rows to know each other.
To calculate the exact maximum width of column two, you have to check each entry.
If you can do this BEFORE creating the combo, you could do this in a loop similar to this pseudo code
FontMetrics fm= jComboBox1.getFontMetrics(jComboBox1.getFont());
foreach (column2String) {
int length= fm.stringWidth(column2String);
if (length>max) max= length;
}Now you have a max value to dimension jLabel2 in your renderer.
If you don't fill your combo in one go, but rather at runtime, you have to check at each
jComboBox1.addItem(...)
whether the string for label2 is extending the current max, redefine max, and repaint the combo.
This second approach I haven't done so far, but that's how I would try. -
I am developing a desktop application in Wpf using MVVM and Entity Frameworks. I have the following tables:
1. Party (PartyId, Name)
2. Case (CaseId, CaseNo)
3. Petitioner (CaseId, PartyId) ............. Link Table
I am completely new to .Net and to begin with I download Microsoft's sample application and
following the pattern I have been successful in creating several tabs. The problem started only when I wanted to implement many-to-many relationship. The sample application has not covered the scenario where there can be a any-to-many relationship. However
with the help of MSDN forum I came to know about a link table and managed to solve entity framework issues pertaining to many-to-many relationship. Here is the screenshot of my application to show you what I have achieved so far.
And now the problem I want the forum to address is how to bind a combo box so that it retrieves Party.Name for the corresponding PartyId in the Link Table and also I want to populate it with Party.Name so that
users can choose one from the dropdown list to add or edit the petitioner.Hello Barry,
Thanks a lot for responding to my query. As I am completely new to .Net and following the pattern of Microsoft's Employee Tracker sample it seems difficult to clearly understand the concept and implement it in a scenario which is different than what is in
the sample available at the link you supplied.
To get the idea of the thing here is my code behind of a view vBoxPetitioner:
<UserControl x:Class="CCIS.View.Case.vBoxPetitioner"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:v="clr-namespace:CCIS.View.Case"
xmlns:vm="clr-namespace:CCIS.ViewModel.Case"
mc:Ignorable="d"
d:DesignWidth="300"
d:DesignHeight="200">
<UserControl.Resources>
<DataTemplate DataType="{x:Type vm:vmPetitioner}">
<v:vPetitioner Margin="0,2,0,0" />
</DataTemplate>
</UserControl.Resources>
<Grid>
<HeaderedContentControl>
<HeaderedContentControl.Header>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<TextBlock Margin="2">
<Hyperlink Command="{Binding Path=AddPetitionerCommand}">Add Petitioner</Hyperlink>
| <Hyperlink Command="{Binding Path=DeletePetitionerCommand}">Delete</Hyperlink>
</TextBlock>
</StackPanel>
</HeaderedContentControl.Header>
<ListBox BorderThickness="0" SelectedItem="{Binding Path=CurrentPetitioner, Mode=TwoWay}" ItemsSource="{Binding Path=tblParties}" />
</HeaderedContentControl>
</Grid>
</UserControl>
This part is working fine as it loads another view that is vPetioner perfectly in the manner I want it to be.
Here is the code of vmPetitioner, a ViewModel:
Imports Microsoft.VisualBasic
Imports System.Collections.ObjectModel
Imports System
Imports CCIS.Model.Party
Namespace CCIS.ViewModel.Case
''' <summary>
''' ViewModel of an individual Email
''' </summary>
Public Class vmPetitioner
Inherits vmParty
''' <summary>
''' The Email object backing this ViewModel
''' </summary>
Private petitioner As tblParty
''' <summary>
''' Initializes a new instance of the EmailViewModel class.
''' </summary>
''' <param name="detail">The underlying Email this ViewModel is to be based on</param>
Public Sub New(ByVal detail As tblParty)
If detail Is Nothing Then
Throw New ArgumentNullException("detail")
End If
Me.petitioner = detail
End Sub
''' <summary>
''' Gets the underlying Email this ViewModel is based on
''' </summary>
Public Overrides ReadOnly Property Model() As tblParty
Get
Return Me.petitioner
End Get
End Property
''' <summary>
''' Gets or sets the actual email address
''' </summary>
Public Property fldPartyId() As String
Get
Return Me.petitioner.fldPartyId
End Get
Set(ByVal value As String)
Me.petitioner.fldPartyId = value
Me.OnPropertyChanged("fldPartyId")
End Set
End Property
End Class
End Namespace
And below is the ViewMode vmParty which vmPetitioner Inherits:
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports CCIS.Model.Case
Imports CCIS.Model.Party
Imports CCIS.ViewModel.Helpers
Namespace CCIS.ViewModel.Case
''' <summary>
''' Common functionality for ViewModels of an individual ContactDetail
''' </summary>
Public MustInherit Class vmParty
Inherits ViewModelBase
''' <summary>
''' Gets the underlying ContactDetail this ViewModel is based on
''' </summary>
Public MustOverride ReadOnly Property Model() As tblParty
'''' <summary>
'''' Gets the underlying ContactDetail this ViewModel is based on
'''' </summary>
'Public MustOverride ReadOnly Property Model() As tblAdvocate
''' <summary>
''' Gets or sets the name of this department
''' </summary>
Public Property fldName() As String
Get
Return Me.Model.fldName
End Get
Set(ByVal value As String)
Me.Model.fldName = value
Me.OnPropertyChanged("fldName")
End Set
End Property
''' <summary>
''' Constructs a view model to represent the supplied ContactDetail
''' </summary>
''' <param name="detail">The detail to build a ViewModel for</param>
''' <returns>The constructed ViewModel, null if one can't be built</returns>
Public Shared Function BuildViewModel(ByVal detail As tblParty) As vmParty
If detail Is Nothing Then
Throw New ArgumentNullException("detail")
End If
Dim e As tblParty = TryCast(detail, tblParty)
If e IsNot Nothing Then
Return New vmPetitioner(e)
End If
Return Nothing
End Function
End Class
End Namespace
And final the code behind of the view vPetitioner:
<UserControl x:Class="CCIS.View.Case.vPetitioner"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:CCIS.ViewModel.Case"
mc:Ignorable="d"
Width="300">
<UserControl.Resources>
<ResourceDictionary Source=".\CompactFormStyles.xaml" />
</UserControl.Resources>
<Grid>
<Border Style="{StaticResource DetailBorder}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="Petitioner:" />
<ComboBox Grid.Column="1" Width="240" SelectedValuePath="." SelectedItem="{Binding Path=tblParty}" ItemsSource="{Binding Path=PetitionerLookup}" DisplayMemberPath="fldName" />
</Grid>
</Border>
</Grid>
</UserControl>
The problem, presumably, seems to be is that the binding path "PetitionerLookup" of the ItemSource of the Combo box in the view vPetitioner exists in a different ViewModel vmCase which serves as an ObservableCollection for MainViewModel. Therefore,
what I need to Know is how to route the binding path if it exists in a different ViewModel?
Sir, I look forward to your early reply bringing a workable solution to the problem I face.
Warm Regards,
Arun -
How can I make the combo box turn to the value of black.
When the show button is pressed (and not before), a filled black square should be
displayed in the display area. The combo box (or drop down list) that enables the user to choose the colour of
the displayed shape and the altering should take effect immediately.When the show button is pressed,
the image should immediately revert to the black square, the combo box should show the value that
correspond to the black.
Now ,the problem is: after I pressed show button, the image is reverted to the black square,but I don't know
how can I make the combo box turn to the value of black.
Any help or hint?Thanks a lot!
coding 1.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class test extends JFrame {
private JPanel buttonPanel;
private DrawPanel myPanel;
private JButton showButton;
private JComboBox colorComboBox;
private boolean isShow;
private int shape;
private boolean isFill=true;
private String colorNames[] = {"black", "blue", "cyan", "darkGray", "gray",
"green", "lightgray", "magenta", "orange",
"pink", "red", "white", "yellow"}; // color names list in ComboBox
private Color colors[] = {Color.black, Color.blue, Color.cyan, Color.darkGray,
Color.gray, Color.green, Color.lightGray, Color.magenta,
Color.orange, Color.pink, Color.red, Color.white, Color.yellow};
public test() {
super("Draw Shapes");
// creat custom drawing panel
myPanel = new DrawPanel(); // instantiate a DrawPanel object
myPanel.setBackground(Color.white);
// set up showButton
// register an event handler for showButton's ActionEvent
showButton = new JButton ("show");
showButton.addActionListener(
// anonymous inner class to handle showButton events
new ActionListener() {
// draw a black filled square shape after clicking showButton
public void actionPerformed (ActionEvent event) {
// call DrawPanel method setShowStatus and pass an parameter
// to decide if show the shape
myPanel.setShowStatus(true);
isShow = myPanel.getShowStatus();
shape = DrawPanel.SQUARE;
// call DrawPanel method setShape to indicate shape to draw
myPanel.setShape(shape);
// call DrawPanel method setFill to indicate to draw a filled shape
myPanel.setFill(true);
// call DrawPanel method draw
myPanel.draw();
myPanel.setFill(true);
myPanel.setForeground(Color.black);
}// end anonymous inner class
);// end call to addActionListener
// set up colorComboBox
// register event handlers for colorComboBox's ItemEvent
colorComboBox = new JComboBox(colorNames);
colorComboBox.setMaximumRowCount(5);
colorComboBox.addItemListener(
// anonymous inner class to handle colorComboBox events
new ItemListener() {
// select shape's color
public void itemStateChanged(ItemEvent event) {
if(event.getStateChange() == ItemEvent.SELECTED)
// call DrawPanel method setForeground
// and pass an element value of colors array
myPanel.setForeground(colors[colorComboBox.getSelectedIndex()]);
myPanel.draw();
}// end anonymous inner class
); // end call to addItemListener
// set up panel containing buttons
buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(4, 1, 0, 50));
buttonPanel.add(showButton);
buttonPanel.add(colorComboBox);
JPanel radioButtonPanel = new JPanel();
radioButtonPanel.setLayout(new GridLayout(2, 1, 0, 20));
Container container = getContentPane();
container.setLayout(new BorderLayout(10,10));
container.add(myPanel, BorderLayout.CENTER);
container.add(buttonPanel, BorderLayout.EAST);
setSize(500, 400);
setVisible(true);
public static void main(String args[]) {
test application = new test();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
coding 2
import java.awt.*;
import javax.swing.*;
public class DrawPanel extends JPanel {
public final static int CIRCLE = 1, SQUARE = 2;
private int shape;
private boolean fill;
private boolean showStatus;
private int shapeSize = 100;
private Color foreground;
// draw a specified shape
public void paintComponent (Graphics g){
super.paintComponent(g);
// find center
int x=(getSize().width-shapeSize)/2;
int y=(getSize().height-shapeSize)/2;
if (shape == CIRCLE) {
if (fill == true){
g.setColor(foreground);
g.fillOval(x, y, shapeSize, shapeSize);
else{
g.setColor(foreground);
g.drawOval(x, y, shapeSize, shapeSize);
else if (shape == SQUARE){
if (fill == true){
g.setColor(foreground);
g.fillRect(x, y, shapeSize, shapeSize);
else{
g.setColor(foreground);
g.drawRect(x, y, shapeSize, shapeSize);
// set showStatus value
public void setShowStatus (boolean s) {
showStatus = s;
// return showstatus value
public boolean getShowStatus () {
return showStatus;
// set fill value
public void setFill(boolean isFill) {
fill = isFill;
// set shape value
public void setShape(int shapeToDraw) {
shape = shapeToDraw;
// set shapeSize value
public void setShapeSize(int newShapeSize) {
shapeSize = newShapeSize;
// set foreground value
public void setForeground(Color newColor) {
foreground = newColor;
// repaint DrawPanel
public void draw (){
if(showStatus == true)
repaint();Hello,
does setSelectedIndex(int anIndex)
do what you need?
See Java Doc for JComboBox. -
SBO 2005 combo box does not update value at first time
Hi!I developed an addon for sbo 2004 with a combo box populated with the months of the year, and it works. The same code run on SBO 2005 works only after the second selection. Has anyone found the same problem?
definition of the item:
item = form.Items.Add("oMese", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX)
item.Left = 245
item.Top = 5
item.Width = 80
item.DisplayDesc = True
combo = item.Specific
combo.DataBind.SetBound(True, "", "uMese")
combo.ValidValues.Add(1, "Gennaio")
combo.ValidValues.Add(2, "Febbraio")
event handling:
inside ItemEvent in case the item is selected
Case SAPbouiCOM.BoEventTypes.et_COMBO_SELECT
Select Case pVal.FormUID
Case "PRG_UFM_0002_RegIVAAcq"
retCode = oTy_RACQ.FormComboSelect(pVal, BubbleEvent)
Public Shared Function FormComboSelect(ByVal pVal As SAPbouiCOM.ItemEvent, _
ByRef BubbleEvent As Boolean, _
ByRef funCaller As Object, _
ByVal funCallerID As Integer, _
ByRef aForm As SAPbouiCOM.Form) _
As Integer
Dim msg As String
Dim edt As SAPbouiCOM.EditText
Dim cmb As SAPbouiCOM.ComboBox
Dim obt As SAPbouiCOM.OptionBtn
Dim cbx As SAPbouiCOM.CheckBox
Dim mtx As SAPbouiCOM.Matrix
Try
If pVal.Before_Action = True Then
Select Case pVal.ItemUID
Case "oMese"
Dim stre As New strEstremi
cmb = aForm.Items.Item("oMese").Specific
edt = aForm.Items.Item("anno").Specific
If Not cmb.Selected Is Nothing Then
GetEstremiPeriod(edt.Value, cmb.Selected.Value, "M", stre)
edt = aForm.Items.Item("dtFrom").Specific
edt.String = stre.dtFrom
edt = aForm.Items.Item("dtTo").Specific
edt.String = stre.dtTo
End If
end function
thank you I hope is enough otherwise please tell me -
Looping through an array to get the index for each measure in a combo box
Hi folks,
I am working on a web application that has two combo boxes, one for year (called yearcombo) and for measures (called myURL) for that selected year, and also two radiobuttons (in radioBtnGroup). I have two years and a bunch of measure for each year. I have a map tool tip that when you mouse over the county you see a measure for that specific year. However I have a bunch of measures for each year and I want to be able to loop through the measures (which are in an array collection inside a combobox) so my "if" expression can find every selectedIndex and bring me the tool tip for that selected measure for that selected radio button. Right now I would have to create if statements for each measure (each selectedIndex inside the myURL combobox)and each radiobutton (inside the radioBtnGroup) instead of creating a if expression to get a map tip tool for each measure. I know I would have to create a loop to search for these indexes and enter that in the if expression and also change the graphic.attributes to reflect the right measure or index selected. Do you API for Flex wizards can give me any tips on how to code this according to my code below ? Any help is greatly appreciated! (the print scree is attached)
Below is the code snippet:
if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 0 && radioBtnGroup.selectedValue == 0)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirIndOut.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
And below is the combo boxes with the arrays
<mx:FormItem label="Year :" >
<mx:ComboBox id="yearcombo" selectedIndex="0" labelField="label" width="100%" change="changeEvt(event)" >
<mx:ArrayCollection id="year" >
<fx:Object label="2007" year="2007" />
<fx:Object label="2009" year="2009" />
</mx:ArrayCollection>
</mx:ComboBox>
</mx:FormItem>
<mx:FormItem label="Measure:">
<mx:ComboBox id="myURL" selectedIndex="8" width="80%" mouseOver="clickEv2(event)" close="closeHandler(event)">
<mx:ArrayCollection id="measures" >
<fx:Object id="forindout07" labeltext="2007 Forestry Industry Output" label="Forestry Industry Output " value="RADIO_BUTTONS/TFEI_07_forest_industry_output" year="2007" />
<fx:Object id="foremp07" label="2007 Forestry Employment " value="RADIO_BUTTONS/TFEI_07_forest_employment" year="2007" />
<fx:Object id="forlabinc07" label="2007 Forestry Labor Income " value="RADIO_BUTTONS/TFEI_07_forest_labincome" year="2007" />
<fx:Object id="forindbustax07" label="2007 Forestry Indirect Business Tax" value="RADIO_BUTTONS/TFEI_07_forest_business_tax" year="2007" />
<fx:Object id="forindout09" label="Forestry Industry Output " value="RADIO_BUTTONS/TFEI_09_forest_industry_output" year="2009" />
<fx:Object id="foremp09" label="2009 Forestry Employment " value="RADIO_BUTTONS/TFEI_09_forest_employment" year="2009" />
<fx:Object id="forlabinc09" label="2009 Forestry Labor Income " value="RADIO_BUTTONS/TFEI_09_forest_labincome" year="2009" />
<fx:Object id="forindbustax09" label="2009 Forestry Indirect Business Tax" value="RADIO_BUTTONS/TFEI_09_forest_business_tax" year="2009" />
<fx:Object id="blank" label=" " />
</mx:ArrayCollection>And here is the entire code
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:esri="http://www.esri.com/2008/ags"
paddingBottom="8" paddingLeft="8"
paddingRight="8" paddingTop="8"
backgroundColor="0xffffff"
layout="vertical" >
<!-- Start Declarations -->
<fx:Declarations>
<esri:SimpleFillSymbol id="mouseOverSymbol" alpha="0.5" color="0x808080">
<esri:SimpleLineSymbol width="0" color="#000000"/>
</esri:SimpleFillSymbol>
<esri:SimpleFillSymbol id="defaultsym" alpha="0.01" color="#E0E0E0" >
<esri:SimpleLineSymbol width="1" color="#000000"/>
</esri:SimpleFillSymbol>
<!-- End Declarations -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import com.esri.ags.Graphic;
import com.esri.ags.SpatialReference;
import com.esri.ags.esri_internal;
import com.esri.ags.events.GraphicEvent;
import com.esri.ags.geometry.Extent;
import com.esri.ags.layers.ArcGISDynamicMapServiceLayer;
import com.esri.ags.symbols.SimpleFillSymbol;
import com.esri.ags.symbols.SimpleLineSymbol;
import flash.utils.flash_proxy;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.controls.RadioButton;
import mx.controls.TextArea;
import mx.events.DropdownEvent;
import mx.events.ItemClickEvent;
import mx.rpc.Fault;
import mx.rpc.events.FaultEvent;
import flash.display.Sprite;
import flash.events.ErrorEvent;
import flash.events.MouseEvent;
private function closeHandler(evt:DropdownEvent):void {
myLabel.text = ComboBox(evt.target).selectedItem.labeltext;
private function loadLayerName():void
myLegend.layers = null;
layerPanel.removeAllChildren();
//loop through each layer and add as a radiobutton
for(var i:uint = 0; i < (dynamicLayer.layerInfos.length); i++)
var radioBtn:RadioButton = new RadioButton;
radioBtn.groupName = "radioBtnGroup";
radioBtn.value = i;
radioBtn.label = dynamicLayer.layerInfos[i].name;
if (dynamicLayer.layerInfos[i].name == "Direct Impact (Million $)")
radioBtn.label = "Direct Impact";
else if (dynamicLayer.layerInfos[i].name == "Total Impact (Million $)")
{radioBtn.label = "Total Impact";
else if (dynamicLayer.layerInfos[i].name == "Total Impact (Jobs)")
{radioBtn.label = "Total Impact";
else if (dynamicLayer.layerInfos[i].name == "Direct Impact (Jobs)")
{radioBtn.label = "Direct Impact";
else
{radioBtn.visible= false;
layerPanel.addChild(radioBtn);
/* myDividerBox.getDividerAt(0).visible = false; */
//set the visible layer the first radio button
radioBtnGroup.selectedValue = 0;
dynamicLayer.visibleLayers = new ArrayCollection([0]);
myLegend.layers = [dynamicLayer];
myLegend.visible = true;
private function radioClickHandler(event:ItemClickEvent):void
myLegend.layers = null;
// update the visible layers to only show the layer selected
dynamicLayer.visibleLayers = new ArrayCollection([event.index]);
myLegend.layers = [dynamicLayer];
private function changeEvt(event:Event):void {
if (yearcombo.selectedItem.year == "2007")
measures.filterFunction=filter1
measures.refresh()
myURL.dataProvider=measures
else if (yearcombo.selectedItem.year == "2009")
measures.filterFunction=filter2
measures.refresh();
public function filter1(item:Object):Boolean
if (item.year=="2007") return true
else return false
public function filter2(item:Object):Boolean
if (item.year=="2009") return true
else return false
private function clickEvt(event:Event):void {
if (yearcombo.selectedItem.year == "2007")
measures.filterFunction=filter3
measures.refresh()
myURL.dataProvider=measures
else if (yearcombo.selectedItem.year == "2009")
measures.filterFunction=filter4
measures.refresh();
public function filter3(item:Object):Boolean
if (item.year=="2007") return true
else return false
public function filter4(item:Object):Boolean
if (item.year=="2009") return true
else return false
private function clickEv2(event:Event):void {
if (yearcombo.selectedItem.year == "2007")
measures.filterFunction=filter5
measures.refresh()
else if (yearcombo.selectedItem.year == "2009")
measures.filterFunction=filter6
measures.refresh();
else if (yearcombo.selectedItem.year == 2007 && myURL.selectedIndex==8)
myLegend.layers = null;
layerPanel.removeAllChildren();
public function filter5(item:Object):Boolean
if (item.year=="2007") return true
else return false
public function filter6(item:Object):Boolean
if (item.year=="2009") return true
else return false
/* IF YOU WANT TO INCLUDE OTHER VALUES IN THE MAP TOOLTIP LIKE COUNTY NAME AND THE LABEL OF THE SELECTED ITEM
if (myURL.selectedIndex==0)
myTextArea.htmlText = "<b>County: </b>" + gr.attributes.NAME + "\n"
+ "<b>Measure: </b>" + myURL.selectedItem.label + gr.attributes.ForDirIndOut.toString()
public function fLayer_graphicAddHandler(event:GraphicEvent):void
event.graphic.addEventListener(MouseEvent.MOUSE_OVER, onMouseOverHandler);
event.graphic.addEventListener(MouseEvent.MOUSE_OUT, onMouseOutHandler);
public function onMouseOverHandler(event:MouseEvent):void
if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 0 && radioBtnGroup.selectedValue == 0)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirIndOut.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 0 && radioBtnGroup.selectedValue == 1)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpIndOut.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 1 && radioBtnGroup.selectedValue == 0)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirEmp.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 1 && radioBtnGroup.selectedValue == 1)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpEmp.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 2 && radioBtnGroup.selectedValue == 0)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirLabInc.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 2 && radioBtnGroup.selectedValue == 1)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpLabInc.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2007" && myURL.selectedIndex == 3 )
fLayer.definitionExpression = "DATA_YEAR_TXT like '2007'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForIndirBusTax.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 0 && radioBtnGroup.selectedValue == 0)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirIndOut.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 0 && radioBtnGroup.selectedValue == 1)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpIndOut.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 1 && radioBtnGroup.selectedValue == 0)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirEmp.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 1 && radioBtnGroup.selectedValue == 1)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpEmp.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 2 && radioBtnGroup.selectedValue == 0)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForDirLabInc.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 2 && radioBtnGroup.selectedValue == 1)
fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForTotImpLabInc.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
if (yearcombo.selectedItem.year == "2009" && myURL.selectedIndex == 3 )
fLayer.definitionExpression = "DATA_YEAR_TXT like '2009'"
var graphic:Graphic = Graphic(event.currentTarget);
graphic.symbol = mouseOverSymbol;
var htmlText:String = graphic.attributes.htmlText;
var textArea:TextArea = new TextArea();
try{
textArea.htmlText = myURL.selectedItem.label + graphic.attributes.ForIndirBusTax.toString()
myMap.infoWindow.content=textArea
myMap.infoWindow.label = graphic.attributes.NAME;
myMap.infoWindow.closeButtonVisible = false;
myMap.infoWindow.show(myMap.toMapFromStage(event.stageX, event.stageY));}
catch(error:Error) {
trace("Caught Error: "+error);
public function onMouseOutHandler(event:MouseEvent):void
var gr:Graphic = Graphic(event.target);
gr.symbol = defaultsym;
myMap.infoWindow.hide();
]]>
</fx:Script>
<fx:Style>
@namespace esri "http://www.esri.com/2008/ags";
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
@namespace esri "http://www.esri.com/2008/ags";
@namespace components "com.esri.ags.components.*";
components|InfoWindow
content-background-alpha : 0.4;
background-color : #4A7138;
background-alpha : 0.7;
border-style : solid;
</fx:Style>
<mx:HBox width="930" height="800" id="mapHbox" horizontalAlign="center" >
<mx:HBox width="80">
</mx:HBox>
<mx:HBox id="myHBox" width="800" height="600" backgroundColor="0xffffff" >
<mx:VBox height="590" width="358" >
<!-- <mx:Panel
width="356" height="100%"
color="0x000000"
borderAlpha="0.15"
>
-->
<mx:Canvas height="100%" width="100%" backgroundColor="0xffffff" >
<esri:Map id="myMap" openHandCursorVisible="false"
height="100%"
logoVisible="false"
doubleClickZoomEnabled="false"
scrollWheelZoomEnabled="false"
zoomSliderVisible="false"
scaleBarVisible="false" scale="4000000" >
<esri:extent>
<esri:Extent xmin="-10736651.061900" ymin="4024099.909700" xmax="-10409195.669800" ymax="3440153.831100" >
<esri:SpatialReference wkid="102100"/>
</esri:Extent>
</esri:extent>
<esri:ArcGISDynamicMapServiceLayer id="dynamicLayer2"
url="http://tfs-24279/ArcGIS/rest/services/RADIO_BUTTONS/counties_layer/MapServer" />
<esri:ArcGISDynamicMapServiceLayer id="dynamicLayer" name=" "
alpha="1"
load="loadLayerName()"
url="http://tfs-24279/ArcGIS/rest/services/{myURL.selectedItem.value}/MapServer" />
<esri:FeatureLayer id="fLayer"
graphicAdd="fLayer_graphicAddHandler(event)"
mode="snapshot"
outFields="*"
symbol="{defaultsym}"
url= "http://tfs-24279/ArcGIS/rest/services/RADIO_BUTTONS/feature_layer_0709_five/FeatureServer/ 0" />
</esri:Map>
</mx:Canvas>
<!-- </mx:Panel>-->
</mx:VBox>
<mx:VBox height="590" width="20" >
</mx:VBox>
<mx:Canvas height="500" width="400" backgroundColor="0xffffff"
horizontalScrollPolicy="off"
verticalScrollPolicy="off" >
<mx:VBox width="420" height="50%" paddingLeft="5" paddingTop="10" paddingRight="10" paddingBottom="10"
verticalGap="8">
<mx:Form >
<mx:FormItem label="Year :" >
<mx:ComboBox id="yearcombo" selectedIndex="0" labelField="label" width="100%" change="changeEvt(event)" >
<mx:ArrayCollection id="year" >
<fx:Object label="2007" year="2007" />
<fx:Object label="2009" year="2009" />
</mx:ArrayCollection>
</mx:ComboBox>
</mx:FormItem>
<mx:FormItem label="Measure:">
<mx:ComboBox id="myURL" selectedIndex="8" width="80%" mouseOver="clickEv2(event)" close="closeHandler(event)">
<mx:ArrayCollection id="measures" >
<fx:Object id="forindout07" labeltext="Forestry Industry Output" label="Forestry Industry Output " value="RADIO_BUTTONS/TFEI_07_forest_industry_output" year="2007" />
<fx:Object id="foremp07" label="Forestry Employment " value="RADIO_BUTTONS/TFEI_07_forest_employment" year="2007" />
<fx:Object id="forlabinc07" label="Forestry Labor Income " value="RADIO_BUTTONS/TFEI_07_forest_labincome" year="2007" />
<fx:Object id="forindbustax07" label="Forestry Indirect Business Tax" value="RADIO_BUTTONS/TFEI_07_forest_business_tax" year="2007" />
<fx:Object id="forindout09" label="Forestry Industry Output " value="RADIO_BUTTONS/TFEI_09_forest_industry_output" year="2009" />
<fx:Object id="foremp09" label="Forestry Employment " value="RADIO_BUTTONS/TFEI_09_forest_employment" year="2009" />
<fx:Object id="forlabinc09" label="Forestry Labor Income " value="RADIO_BUTTONS/TFEI_09_forest_labincome" year="2009" />
<fx:Object id="forindbustax09" label="Forestry Indirect Business Tax" value="RADIO_BUTTONS/TFEI_09_forest_business_tax" year="2009" />
<fx:Object id="blank" label=" " />
</mx:ArrayCollection>
</mx:ComboBox>
</mx:FormItem>
</mx:Form>
<mx:VBox id="layerPanel" width="50%" height="8%" verticalGap="3" paddingLeft="17">
<mx:RadioButtonGroup id="radioBtnGroup" itemClick="radioClickHandler(event)" />
</mx:VBox>
<mx:VBox paddingLeft="17" height="50%" >
<mx:Canvas id="legendPanel" width="100%" >
<mx:Label id="myLabel" text=" " fontWeight="bold" />
<esri:Legend id="myLegend"
layers="{[dynamicLayer]}"
map="{myMap}" visible="false"
respectCurrentMapScale="false"/>
</mx:Canvas>
<mx:TextArea width="275" borderAlpha="0" height="200" >
<mx:htmlText >
<![CDATA[<font size='11'><b>Note:</b> Counties in white indicate either no data is available for that measure or the data has been supressed due to confidentiality.</font>
]]>
</mx:htmlText>
</mx:TextArea>
</mx:VBox>
</mx:VBox>
</mx:Canvas>
</mx:HBox>
</mx:HBox>
</mx:Application> -
LOV's in form combo box - how to change font size?
Greetings:
I've a table generated form (custom vs. tabular), with a combo-box field that fills with a LOV's that has as it's visible data, a rather long concatenated string. Therefore, this field makes the entire form rather wide when the LOV's contains a long string (as returned from the SQL that gathers the data).
I've tried using the FONT tag in the 2nd tab (Form wizard) for custom layouts; that didn't work.
Anyone have ideas for decreasing the font size of the LOV's? Else, I'll have to leave-out some of the info concatenated on that string.
As always, thanks for you continued guidance and support...
Ed in TampaHi,
Changing the font size and other properties like font color, width, height, etc.. of the form elements can be achieved by using Cascading Style Sheet (CSS).
It cannot be changed using <FONT> tag.
In Portal, one can add the CSS attribute to the HTML tags in the custom layout of the form. But adding the CSS attribute to FORM elements (Input, select..)is not possible through Form wizards.
However, this can be achieved by creating a form through the Dynamic Page. In this case you have to define your whole form.
To know more about CSS you can visit: http://www.mako4css.com
Thanks,
Shivank -
Combo box list getting widened while selecting
I have an application , which have combo boxes inside a DIV tag.
When the length of one the item in the list box is greater the specified length of the combo box, the display of the list gets widened and the combo box widens to the lengthiest items' length and it looks odd.
I want the options to fit to the length of the combo box specified.Could you post a link to a page (actual page or test case) demonstrating the problem?
How are you constraining the width of the <select> control -- have you tried CSS max-width? -
Combo Box Selection Issue in SBO 2007
Hello.
Here is one issue which I am facing now.
I have just installed the 2007 Version of SBO in my machine. And using VB.Net.
When I tried to retrieve the <i>Selected.Value</i> from a ComboBox, it is returning a wrong value.
The real problem is this.
Suppose there is two ValidValues in the Combo box
1. <b>aaa</b>
2. <b>bbb</b>
and suppose we manually selected the value '<b>aaa</b>' in it.
Then the combobox will show '<b>aaa</b>' as selected value.
When we try to return it using the <i>Selected.Value</i> property, it returns <b>aaa</b>.
then I tried to select '<b>bbb</b>' using a code which is here
<i>oCombo.Select("bbb",SAPBouicom.BoSearchKey.psk_ByValue)</i>
Now the combobox will show '<b>bbb</b>' as selected value. But,
When we try to return it using <i>Selected.Value</i> property, It still returns <b>aaa</b>.
If we select <b>bbb</b> manually, it will return <b>bbb</b>.
IT ALWAYS RETURNS THE LAST MANUALLY SELECTED VALUE.
here is the original Code which I tried in my application.
<i>cboCategory.Select(CWRptMaint.ReportCategory, SAPbouiCOM.BoSearchKey.psk_ByValue)
Dim s As String = cboCategory.Selected.Value
Dim t As String = cboCategory.Selected.Description
</i>
Please Help me to solve this issue.
Thank you
AnoopHI
I never had a problem about combobox not using datasource
But here's the example code about combobox using datasource and not using datasource that i'm taken from one of my friend's project (VB6)
'================================================================
Public Type objectReportBA
oComboBox As SAPbouiCOM.ComboBox
oComboBox2 As SAPbouiCOM.ComboBox
oUserDataSource As SAPbouiCOM.UserDataSource
End Type
Public oRBA As objectReportBA
'==================================================================
'// example Adding a Combo Box item not using user data source
Set oItem = oFormReportBA.Items.Add("RCB1", it_COMBO_BOX)
oItem.Left = 70
oItem.Width = 85
oItem.Top = 4
oItem.Height = 18
oItem.DisplayDesc = True
Set oRBA.oComboBox = oItem.Specific
oRBA.oComboBox.ValidValues.Add "1", "aaa"
oRBA.oComboBox.ValidValues.Add "2", "bbb"
oRBA.oComboBox.Select "bbb", psk_ByValue
SBO_Application.MessageBox "Combo1->" & oRBA.oComboBox.Selected.Value '<<<< will get a value = 2
SBO_Application.MessageBox "Combo1->" & oRBA.oComboBox.Selected.Description '<<<< will get a description = bbb
'==================================================================
'// example Adding another Combo Box item and using datasource
Set oItem = oFormReportBA.Items.Add("RCB2", it_COMBO_BOX)
oItem.Left = 157
oItem.Width = 163
oItem.Top = 24
oItem.Height = 14
oItem.DisplayDesc = True
Set oRBA.oComboBox2 = oItem.Specific
oRBA.oComboBox2.ValidValues.Add "1", "aaa"
oRBA.oComboBox2.ValidValues.Add "2", "bbb"
oFormReportBA.DataSources.UserDataSources.Add "CombSource", dt_LONG_TEXT, 30
oRBA.oComboBox2.DataBind.SetBound True, "", "CombSource"
Set oRBA.oUserDataSource = oFormReportBA.DataSources.UserDataSources.Item("CombSource")
oRBA.oUserDataSource.Value = "bbb"
SBO_Application.MessageBox "Combo2->" & oRBA.oUserDataSource.Value '<<< will get a value = bbb (but u will get diferent value if u click the combobox manually)
'======================================================================
'if you click the combobox manually using itemEvent
Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, pVal As SAPbouiCOM.IItemEvent, BubbleEvent As Boolean)
Select Case pVal.ItemUID
Case "RCB1": '//combobox object not using datasource
If pVal.EventType = et_COMBO_SELECT Then
If pVal.BeforeAction = False Then
SBO_Application.MessageBox "combo1->" & oRBA.oComboBox.Selected.Description '<<<< will get a description = aaa or bbb
End If
End If
Case "RCB2": '//Combobox object that using datasource
If pVal.EventType = et_COMBO_SELECT Then
If pVal.BeforeAction = False Then
SBO_Application.MessageBox "combo2->" & oRBA.oUserDataSource.Value '<<<< will get a descriptian = 1 or 2
SBO_Application.MessageBox "combo2->" & oRBA.oComboBox2.Selected.Description '<<<< will get a description = aaa or bbb
End If
End If
end select
end sub
'===============================================================
Hopefully this will Help You Anoop
Regards
Ancumen -
I have looked everywhere and I am having a hard time finding
a good example of how to use a combo box in a datagrid. I want to
use a dataprovider for my datagird but as soon as I get inside my
itemRenderer it throws an error saying Access of undefined property
model even though it is defined above. Can someone please help me.
I may be way off??
<mx:DataGrid x="10" y="10" width="840" height="120"
dataProvider="{model.acProducts}">
<mx:columns>
<mx:DataGridColumn dataField="UPC Number">
<mx:itemRenderer>
<mx:Component>
<mx:ComboBox
dataProvider="{model.acProducts}"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn dataField="proddesc"
headerText="Product Name" />
<mx:DataGridColumn headerText="Lot Number" />
<mx:DataGridColumn headerText="Product Category" />
<mx:DataGridColumn headerText="EPA" />
<mx:DataGridColumn headerText="AE Count">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalAlign="center">
<mx:Script>
<![CDATA[
[Bindable]
public var selected:Boolean;
]]>
</mx:Script>
<mx:CheckBox id="displayCheckBox" click="selected =
displayCheckBox.selected"/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>i got it. Heres the code for everyone who is wondering
<mx:DataGrid x="10" y="10" width="840" height="120"
dataProvider="{model.acProducts}" ro>
<mx:columns>
<mx:DataGridColumn dataField="UPC Number">
<mx:itemRenderer>
<mx:Component>
<mx:HBox>
<mx:Script>
<![CDATA[
import
com.serg.reportingTool.model.SergReportingToolModelLocator;
[Bindable] private var model:SergReportingToolModelLocator =
SergReportingToolModelLocator.getInstance();
]]>
</mx:Script>
<mx:ComboBox
id="occurenceCode"
labelField="OccurrenceCode"
dataProvider="{model.acOccurrences}"
/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn dataField="proddesc"
headerText="Product Name" />
<mx:DataGridColumn headerText="Lot Number" />
<mx:DataGridColumn headerText="Product Category" />
<mx:DataGridColumn headerText="EPA" />
<mx:DataGridColumn headerText="AE Count">
<mx:itemRenderer>
<mx:Component>
<mx:HBox horizontalAlign="center">
<mx:Script>
<![CDATA[
[Bindable]
public var selected:Boolean;
]]>
</mx:Script>
<mx:CheckBox id="displayCheckBox" click="selected =
displayCheckBox.selected"/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid> -
Hi,
How can I modify the combo box (drop down list) dimension in infoview and CMC?
I have a combo box wich is fill with string values from a LOV.Some strings are larger than the width of the combo box and for that i want to increase the width.
Anyone knows if this is possible or not?
And if it is how could be done?
Thanks
Best Regards,
AurelCan you please let me know you fill the combo box with LOV of universe objects?
-
Combo Boxes....again but straight answer required.
Okay so the follwing code:
oItem = oForm.Items.Add("oCombo2", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX)
With oItem
.Height = oXPlaneItem.Height
.Width = oYPlaneItem.Width
.Left = oYPlaneItem.Left
.Top = oXPlaneItem.Top
.DisplayDesc = True
End With
oCombo = oItem.Specific
oCombo.DataBind.SetBound(True, "", "U_Status")
oCombo.ValidValues.Add("1", "Live")
oCombo.ValidValues.Add("2", "Got")
oCombo.ValidValues.Add("3", "Lost")
oCombo.ValidValues.Add("4", "Didn't happen")
Results in a combo box that once selected shows the description only - GREAT!
BUT...... when selecting from the combo box the lists shows VALUE - DESCRIPTION (i.e. 1 - Live), Can this be changed to just show the description.
Apologies if this is answered in another post but I was looking for ages and the difference between selected and combo box selection descriptions was never dictated.
Dave A.Its not possible to show only the description.
Vasu Natari. -
Calling A .SWF through a Combo box.
Hi,
I drag a combo box and provide 3 options January, February
and March. I want to see 3 different .SWF files in the same page
when I choose one of these options. Please help me call the movies
through combo box selection. Here is my code.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:ComboBox xmlns:mx="
http://www.adobe.com/2006/mxml">
<mx:dataProvider>
<mx:ArrayCollection>
<mx:String>January</mx:String>
<mx:String>February</mx:String>
<mx:String>March</mx:String>
</mx:ArrayCollection>
</mx:dataProvider>
</mx:ComboBox>
</mx:Application>
ThanksI would store the filename of the swf within your Combo Box
dataProvider and then when it changes load the new swf based upon
what they chose. I wrote a sample application that achieves this.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable] private var swfDP:ArrayCollection = new
ArrayCollection([
{label:"Choose a Month", data:""},
{label:"January", data:"january.swf"},
{label:"February", data:"february.swf"},
{label:"March", data:"march.swf"}]);
private function onComboChange(event:Event):void {
// => Check to see if swf location exists, if it does
then load the new swf.
(event.currentTarget.selectedItem.data != "") ?
loader.load(event.currentTarget.selectedItem.data) : "";
]]>
</mx:Script>
<mx:ComboBox dataProvider="{swfDP}"
change="onComboChange(event)" />
<mx:SWFLoader id="loader" width="300" height="300" />
</mx:Application>
You will need to change the filename's to match yours unless
they really are named january.swf and what not. Hope this
helps. -
MS Excel/VBA: Querying DB to populate combo boxes
Hi.
I am trying to populate five different combo boxes.
They are in an order of importance - market, product, duration, trade period description and trade date. Therfore, if a user selects a different market, then all of the other combo boxes should automatically update to show, for example, only the products which operate in that market should be visible, and this should be iterated all of the way down the other three combo boxes.
I have written code for this to happen so the query for product only includes those for that market.
However, when I use the ListFillRange to select all of the available products and populate the combo boxes an error occurs sometimes stating "Application-defined or object-defined error". It highlights the .Refresh BackgroundQuery:=False line.
Is there a better way to go about completing this task?
Thanks, Dan.Sometimes I've seen this in access with form, where the database data has either something line a linefeed character or a load of spaces before the actual
text eg " text" in which case the
columns in the control will be too narrow.
You could try udjusting your coulumns width in its control
You might need to loop through each item in the cotrol and adjust using say
the MID() function or the TRIM() function.
Maybe you are looking for
-
Mail V6.3 pdf attachments "the file could not be opened because it is empty"
I received an email with a pdf document attached. When I try to open it by saving it or directly from the email, I get the message "The File 'filename' could not be opened because it is empty." The file extension is correct with .pdf. Adobe is up to
-
TS5181 How can I get iTunes Radio to QUIT automatically playing?!
When I get out of the car and I'm in one of my playlists (created on a computer, not a genius or anything) and I'm in the middle of a song, my issue is when I get back in the car (it can be 5 minutes or 2 hours), my song doesn't pick up from where I
-
How do I cut a line with a rectangle using the Pathfinder
I'm a complete newb in Ai (many years in Ps). I'm trying to cut off (delete) a rectangular section of a grid that is made of many lines. I keep getting the message, "The filter produced no results. Please select two intersecting paths." In its simple
-
Interlaced DVD on (Progressive) HDTV....
I recently (finally) upgraded to an HDTV, and maybe I'm just looking for things, or things are simply more noticable, but...... You know how if you export to DV-AVI, and then watch it in Windows Media Player, it looks all horrible because the file is
-
How do I fill out this document in Adobe?