<p>One of the guys I work with needs a custom control that would work like a multiline ddl since such a thing does not exist as far as we have been able to discover</p>

<p>does anyone have any ideas or have created such a thing before<br>
we have a couple ideas but they involve to much database usage  </p>

<p>We prefer that it be FREE!!!</p>

[{'answer_id': 50543, 'author': 'Espo', 'author_id': 2257, 'author_profile': 'https://Stackoverflow.com/users/2257', 'pm_score': 8, 'selected': True, 'text': '<p>From <a href="http://bytes.com/forum/thread16212.html" rel="noreferrer">this thread</a>, there are different ways to do this:</p>\n\n<pre><code>double r = 5.1234;\nSystem.out.println(r); // r is 5.1234\n\nint decimalPlaces = 2;\nBigDecimal bd = new BigDecimal(r);\n\n// setScale is immutable\nbd = bd.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP);\nr = bd.doubleValue();\n\nSystem.out.println(r); // r is 5.12\n</code></pre>\n\n<hr>\n\n<pre><code>f = (float) (Math.round(n*100.0f)/100.0f);\n</code></pre>\n\n<hr>\n\n<pre><code>DecimalFormat df2 = new DecimalFormat( "#,###,###,##0.00" );\ndouble dd = 100.2397;\ndouble dd2dec = new Double(df2.format(dd)).doubleValue();\n\n// The value of dd2dec will be 100.24\n</code></pre>\n\n<p>The <a href="http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html" rel="noreferrer">DecimalFormat()</a> seems to be the most dynamic way to do it, and it is also very easy to understand when reading others code.</p>\n'}, {'answer_id': 50544, 'author': 'Jeff Atwood', 'author_id': 1, 'author_profile': 'https://Stackoverflow.com/users/1', 'pm_score': 6, 'selected': False, 'text': '<p>You and <code>String.format()</code> will be new best friends!</p>\n\n<p><a href="https://docs.oracle.com/javase/1.5.0/docs/api/java/util/Formatter.html#syntax" rel="nofollow noreferrer">https://docs.oracle.com/javase/1.5.0/docs/api/java/util/Formatter.html#syntax</a></p>\n\n<pre><code> String.format("%.2f", (double)value);\n</code></pre>\n'}, {'answer_id': 50548, 'author': 'ckpwong', 'author_id': 2551, 'author_profile': 'https://Stackoverflow.com/users/2551', 'pm_score': 3, 'selected': False, 'text': '<p>Use <a href="http://java.sun.com/javase/6/docs/api/java/text/DecimalFormat.html" rel="noreferrer">DecimalFormat</a>.</p>\n'}, {'answer_id': 50556, 'author': 'Vinko Vrsalovic', 'author_id': 5190, 'author_profile': 'https://Stackoverflow.com/users/5190', 'pm_score': 4, 'selected': False, 'text': '<p>Round numbers, yes. This is the <a href="http://java.sun.com/docs/books/tutorial/i18n/format/decimalFormat.html#numberpattern" rel="nofollow noreferrer">main example source</a>.   </p>\n\n<pre><code>/*\n * Copyright (c) 1995 - 2008 Sun Microsystems, Inc.  All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n *   - Redistributions of source code must retain the above copyright\n *     notice, this list of conditions and the following disclaimer.\n *\n *   - Redistributions in binary form must reproduce the above copyright\n *     notice, this list of conditions and the following disclaimer in the\n *     documentation and/or other materials provided with the distribution.\n *\n *   - Neither the name of Sun Microsystems nor the names of its\n *     contributors may be used to endorse or promote products derived\n *     from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS\n * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\n * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR\n * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */ \n\n\nimport java.util.*;\nimport java.text.*;\n\npublic class DecimalFormatDemo {\n\n    static public void customFormat(String pattern, double value ) {\n        DecimalFormat myFormatter = new DecimalFormat(pattern);\n        String output = myFormatter.format(value);\n        System.out.println(value + "  " + pattern + "  " + output);\n    }\n\n    static public void localizedFormat(String pattern, double value,                                       Locale loc ) {\n        NumberFormat nf = NumberFormat.getNumberInstance(loc);\n        DecimalFormat df = (DecimalFormat)nf;\n        df.applyPattern(pattern);\n        String output = df.format(value);\n        System.out.println(pattern + "  " + output + "  " + loc.toString());\n    }\n\n    static public void main(String[] args) {\n\n        customFormat("###,###.###", 123456.789);\n        customFormat("###.##", 123456.789);\n        customFormat("000000.000", 123.78);\n        customFormat("$###,###.###", 12345.67);\n        customFormat("\\u00a5###,###.###", 12345.67);\n\n        Locale currentLocale = new Locale("en", "US");\n\n        DecimalFormatSymbols unusualSymbols = new DecimalFormatSymbols(currentLocale);\n        unusualSymbols.setDecimalSeparator(\'|\');\n        unusualSymbols.setGroupingSeparator(\'^\');\n        String strange = "#,##0.###";\n        DecimalFormat weirdFormatter = new DecimalFormat(strange, unusualSymbols);\n        weirdFormatter.setGroupingSize(4);\n        String bizarre = weirdFormatter.format(12345.678);\n        System.out.println(bizarre);\n\n        Locale[] locales = {\n            new Locale("en", "US"),\n            new Locale("de", "DE"),\n            new Locale("fr", "FR")\n        };\n\n        for (int i = 0; i &lt; locales.length; i++) {\n            localizedFormat("###,###.###", 123456.789, locales[i]);\n        }\n     }\n }\n</code></pre>\n'}, {'answer_id': 50557, 'author': 'Tom Hawtin - tackline', 'author_id': 4725, 'author_profile': 'https://Stackoverflow.com/users/4725', 'pm_score': 2, 'selected': False, 'text': '<p>There are two approaches in the standard library. One is to use java.text.DecimalFormat. The other more cryptic methods (String.format, PrintStream.printf, etc) based around java.util.Formatter should keep C programmers happy(ish).</p>\n'}, {'answer_id': 50892, 'author': 'Robert J. Walker', 'author_id': 4287, 'author_profile': 'https://Stackoverflow.com/users/4287', 'pm_score': 4, 'selected': False, 'text': '<p>Be aware that classes that descend from NumberFormat (and most other Format descendants) are not synchronized. It is a common (but dangerous) practice to create format objects and store them in static variables in a util class. In practice, it will pretty much always work until it starts experiencing significant load.</p>\n'}, {'answer_id': 22401832, 'author': 'Stefan Haberl', 'author_id': 287138, 'author_profile': 'https://Stackoverflow.com/users/287138', 'pm_score': 2, 'selected': False, 'text': '<p>As Robert has pointed out in his answer: DecimalFormat is neither synchronized nor does the API guarantee thread safety (it might depend on the JVM version/vendor you are using). </p>\n\n<p>Use Spring\'s <a href="http://docs.spring.io/spring/docs/3.0.x/api/org/springframework/format/number/NumberFormatter.html" rel="nofollow">Numberformatter</a> instead, which is thread safe.</p>\n'}, {'answer_id': 25929742, 'author': 'Nautilus', 'author_id': 3706308, 'author_profile': 'https://Stackoverflow.com/users/3706308', 'pm_score': 3, 'selected': False, 'text': '<p>Try this:</p>\n\n<pre><code>String.format("%.2f", 32.302342342342343);\n</code></pre>\n\n<p>Simple and efficient.</p>\n'}, {'answer_id': 45898683, 'author': 'Soner from The Ottoman Empire', 'author_id': 4990642, 'author_profile': 'https://Stackoverflow.com/users/4990642', 'pm_score': 2, 'selected': False, 'text': '<pre><code>public static void formatDouble(double myDouble){\n NumberFormat numberFormatter = new DecimalFormat("##.000");\n String result = numberFormatter.format(myDouble);\n System.out.println(result);\n}\n</code></pre>\n\n<p>For instance, if the double value passed into the formatDouble() method is 345.9372, the following will \nbe the result:\n345.937\nSimilarly, if the value .7697 is passed to the method, the following will be the result:\n.770</p>\n'}]
['https://Stackoverflow.com/questions/50539', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2486/']