?
Solved

Data Grid Formatting

Posted on 2006-07-21
1
Medium Priority
?
242 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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

719 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