473,386 Members | 1,924 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.

datagridColumn.FormatInfo: how can i change the display value of a double to be divided by 100?

Hi all,

I could use a little help.

I am trying to customize a displayed value in a dataGrid. What i would
like to do is create a IFormatProvider
that will set my column to be displayed in terms of 100, where 100 = 1.
I have not been able to figure this one out.
I have been messing around with IFormatProvider and ICustomFormatter
but I am not getting anywhere.
One thing, I can't change the value, this is a display change only.

pseudo code

dataGridTextBoxColumn1.FormatInfo = new
someObjectThatReturnsThisColumnValueDiviededBy100( );

Any help would be greatly appreciated.
Thanks,
Dan Tanzer
su*****@zeramaNOSpammmy.net

Nov 16 '05 #1
2 1523
Hi Dan,

If you are using web forms (I cannot tell by your post win or web) a simple
way to accomplish this is by writing a custom function that returns the data
formatted the way that you would like. For instance in your grid you have

DataBinder.Eval(Container.DataItem, "MyNumber")

to display your number. You can write a simple function like

public int FormatMyContents(string myValue)
{
int i = Convert.ToInt32(myValue);
if(i > 0)
return i/100;
else
return 0;
}

and then wrap the call to DataBinder with your method:

FormatMyContents(DataBinder.Eval(Container.DataIte m, "MyNumber").ToString())

Now when you execute the string the contents will be formatted. If this is
not what you were looking for or I have misunderstood you in any way please
reply to this post.

I hope this helps.
Nov 16 '05 #2
Brian,
Thanks for the reply , I am using a WinForms, so i won't be able to use
your solution.
Thanks for your help.
Dan
Brian Brown wrote:
Hi Dan,

If you are using web forms (I cannot tell by your post win or web) a simple way to accomplish this is by writing a custom function that returns the data formatted the way that you would like. For instance in your grid you have
DataBinder.Eval(Container.DataItem, "MyNumber")

to display your number. You can write a simple function like

public int FormatMyContents(string myValue)
{
int i = Convert.ToInt32(myValue);
if(i > 0)
return i/100;
else
return 0;
}

and then wrap the call to DataBinder with your method:

FormatMyContents(DataBinder.Eval(Container.DataIte m, "MyNumber").ToString())
Now when you execute the string the contents will be formatted. If this is not what you were looking for or I have misunderstood you in any way please reply to this post.

I hope this helps.


Nov 16 '05 #3

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

Similar topics

0
by: Dong | last post by:
Hi All, I am using Visual Studio 2003 (Development Environment version 7.1.3088 and ..NET Framework 1.1 version 1.14322 sp1). But the FormatInfo property never appears in myGridTextBoxColumn...
0
by: andrewcw | last post by:
I am trying to set the column information - which ones I want displayed and how with the web grid control. The interface has some big differences when compared to the winform. Is this possible...
2
by: Andrew | last post by:
I am trying to set the column information - which ones I want displayed and how with the web grid control. The interface has some big differences when compared to the winform. Is this possible...
0
by: support | last post by:
Hi all, I could use a little help. I am trying to customize a displayed value in a dataGrid. What i would like to do is create a IFormatProvider that will set my column to be displayed in...
2
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid...
7
by: Girish | last post by:
OK.. phew. Playing with data grids for the past few days has been fun and a huge learning experience.. My problem. I have a requirement to display a gird with a gird. Within the embedded grid,...
8
by: Radek Budaø | last post by:
Hi all, i have trouble with changing text value of textbox on runtime. I use this control to display process information about sending e-mail per smtp. I use external component >>Imports...
16
by: Martin Jørgensen | last post by:
Hi, Short question: Any particular reason for why I'm getting a warning here: (cast from function call of type int to non-matching type double) xdouble = (double)rand()/(double)RAND_MAX;
6
sammyboy78
by: sammyboy78 | last post by:
I'm trying to display my array of objects in a GUI. How do I get JLabel to refer to the data in my objects? I've read my textbook and some tutorials online I just cannot get this. Plus all the...
4
by: =?Utf-8?B?YjF1Y2VyZWU=?= | last post by:
Hi, still very new to programming but am a little stumped by how to do this idea i have. I need to make a moving average which takes every nth value in a data series to build a running total...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.