473,386 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Formatting & Data Binding

How can I bind to a data source and express a format?

For example:

Let's say I have a function that returns an array of double, like so:
double[] myVals= MyFunctions (param1, ..., paramN);

I want to view the data in a listBox, but I'd like the data to only show n
digits, something like:

listBox1.DataSource = MyVals.ToString("2F"); // I know you can't do
this !!

Hold do I set the numeric formatting type for the listBox?
Nov 16 '05 #1
1 2035
Shmulik wrote:
How can I bind to a data source and express a format?

For example:

Let's say I have a function that returns an array of double, like so:
double[] myVals= MyFunctions (param1, ..., paramN);

I want to view the data in a listBox, but I'd like the data to only show n
digits, something like:

listBox1.DataSource = MyVals.ToString("2F"); // I know you can't do
this !!

Hold do I set the numeric formatting type for the listBox?


Use listbox1.DataTextFormatString to format the data.

Frans

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Saix News | last post by:
hi, i have a dataset and a number of controls that are bound to it. some of the records being displayed are numerical and are bound to text boxes. they display without a problem but i would...
2
by: Von Bailey | last post by:
I have a form where the conditional formatting is set on some fields to bold if certain conditions are met. However, when the conditions are met some of the data that is to bold is either not...
4
by: hope | last post by:
Hi, How can I format a string field using Data Formatting Expression property in datagrid? For example: format last name from BROWN to Brown. Thanks
3
by: washoetech | last post by:
I have a gridview control. In this grid view there is a column for the price of an item. Some of the prices have a dollar sign in front of it and some dont. How do I get rid of the dollar sign...
1
by: msmcg | last post by:
I need to format the data in some textboxes using the Binding method with custom Currency and ShortDate format and parse handlers. Here is the code that I am using. I call it on the form load...
1
by: Bruce | last post by:
Hi, there, I meet a problem about comboBox binding. -------------------- Database: Northwind Tables: 1) Products 2) Categories I create a form (named "form1") to edit the record from...
7
by: Chris | last post by:
Where can I find a fairly comprehensive list of the formatting codes used when data binding. e.g. <%# Bind("Debit", "{0:C}") %>. Specifically formatting a number to 2 decimal places. Regards, Chris.
6
by: Tomasz J | last post by:
Hello developers, I bind my TextBox control specyfying a format stored in my application global ApplicationContext object - it has a static string CurrencyFormat property. The problem - this...
5
by: Berryl Hesh | last post by:
Requirements for a field that represents an EmployeeNumber: · The field is always 6 characters long, and is stored as a 'string' in the db o All characters must be digits § ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.