Solved

Data Grid Formatting

Posted on 2006-07-21
1
241 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
jtaylor8181 earned 250 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

Technology Partners: 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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

623 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