Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Data Grid Formatting

Posted on 2006-07-21
1
Medium Priority
?
243 Views
Last Modified: 2012-06-27
I am binding a data grid to an sql table and one of my columns is a currency. Is there anyway that I can format that one column when it is being loaded?
0
Comment
Question by:mwhodges
1 Comment
 
LVL 4

Accepted Solution

by:
jtaylor8181 earned 1000 total points
ID: 17157138
How are you trying to format it, alignment, font, etc.  If that is the case you can do it programmatically.

With datagrid

.Columns("currency").HeaderText = "Price"

.Columns("currency").DefaultCellStyle.Font = New Font FontFamily.GenericSansSerif, 10.0F, FontStyle.Bold)

.Columns("currency").DefaultCellStyle.Alignment = Forms.DataGridViewContentAlignment.MiddleRight

End With

Then I believe for sql, if you store a value in a database table as currency it will return with extra decimal places, example 10.99 - 10.9900, so what will have to do is format those prices as well.  What you could to is use a dataview and then use a for loop to go through each of the rows and reformat it.

me.m_dv as dataview

For i As Integer = 0 To Me.m_dv.Count - 1

Me.m_dv(i).Item("currency") = Format(Me.m_dv(i).Item("currency"), "0.00")

Next

I hope this is what you were looking for.

jtaylor


0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question