Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Datagridview format rows
 

Datagridview format rows

I want my datagridview to have one row formatted with 2 decimals and second row should not have decimals at all (the values should be rounded).

I use such code

Private
 Sub
 FormatTotalGrid( _
        ByVal
 PercFormat As
 String
, _
        ByVal
 SumFormat As
 String
, _
        ByVal
 dgvSrc As
 DataGridView)


        dgvSrc.Rows(0).DefaultCellStyle.Format = PercFormat
        
        dgvSrc.Rows(1).DefaultCellStyle.Format = SumFormat

        'dgvSrc.Refresh()


    End
 Sub

The problem: I noticed that datagridview should be displayed at least once before such changes can be applied. My datagridviews are on tabpages which are not active at the moment when application starts. So user needs to go to every tabpage and only then I can reapply styles to datagriviews I need to change.

Why such things are happening? Formatting works fine while I format columns. But if I start format rows or cells the formattin is not applied until the control is displayed at least once.
Be cool! Help a noob
The Dwarf  Tuesday, August 25, 2009 12:54 PM
Use DataGridView.CellFormatting Event.
Please mark the post as answer if it is helpfull to you because it boosts the members to answer more and more.
  • Marked As Answer byThe Dwarf Thursday, August 27, 2009 11:50 AM
  •  
_SuDhiR_  Tuesday, August 25, 2009 1:06 PM
Use DataGridView.CellFormatting Event.
Please mark the post as answer if it is helpfull to you because it boosts the members to answer more and more.
  • Marked As Answer byThe Dwarf Thursday, August 27, 2009 11:50 AM
  •  
_SuDhiR_  Tuesday, August 25, 2009 1:06 PM

You can use google to search for other answers

Custom Search

More Threads

• How to limit the number of characters in datagrid cell
• combobox databinding to display more than one values
• DataGridView: how to stop / cancel sorting
• Unretrivable data from single selected checkboxes in datagridview
• How to handle dagagridview cell copy and paste
• How to fill datadridview from texboxes and update access table with new records in datagridview vb.net ms access
• Passing Parameters between Forms
• Why I can not set any DefaultCellStyle after I set DataSource
• Simple Question, Database and windows form, why is not a two way street
• DataGridView : Identifying specific row when adding rows via code