Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: DataGridView format
hello everybody,
 
i have problem with DefaultCellStyle in datagridview,
 
i have 3 column in my bank(Access) and i want when those records come to my datagridview change their format ,
 
for example their format is 12000 but i want to change their format in datagridview like 12,000. this is my code "
 
da.SelectCommand = New OleDbCommand()
 
        With da.SelectCommand
            .Connection = my_con
            .CommandType = CommandType.Text
            .CommandText = "Select p_name,p_fname,p_mablagh from table1"
 
            If .Connection.State <> ConnectionState.Open Then
                .Connection.Open()
            End If
        End With
 
        Dim ds As New Database2DataSet
        da.Fill(ds.Table1)
        Me.DataGridView1.DataSource = ds.Table1
        my_con.Close()
        Me.DataGridView1.Columns(2).DefaultCellStyle.Format = "##,0"
 
first :
 
[URL=http://img4up.com/][IMG]http://img4up.com/up2/47117885029305385819.jpg[/IMG][/URL]
 

want this "
 
[URL=http://img4up.com/][IMG]http://img4up.com/up2/81408470236125767939.jpg[/IMG][/URL]
 

my english is not very well please help me.
 
thanks a lot
Posted 16-Mar-12 2:18am
Hybr!d377
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

i really need that .... please help me....
 
thanks a lot.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

As seen from the images at URL specified in your question, the formatting is required in second Column. So, the Column Index will be 1.
Set the Format property as below
Me.DataGridView1.Columns(1).DefaultCellStyle.Format = "#,0"
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

thank yo for your answer but if u see my code ,
 
i wrote your code in my code ! but it didnt work
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 5,170
1 DamithSL 4,357
2 Maciej Los 3,750
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,851


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 19 Mar 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100