Click here to Skip to main content
15,915,093 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionRDLC Expression for Address in textbox Pin
jkirkerx27-Apr-15 9:46
professionaljkirkerx27-Apr-15 9:46 
AnswerRe: RDLC Expression for Address in textbox Pin
jkirkerx27-Apr-15 10:45
professionaljkirkerx27-Apr-15 10:45 
QuestionFinding the index of a Listbox item, based on search criteria. VB6 Pin
EdwardX227-Apr-15 6:25
EdwardX227-Apr-15 6:25 
AnswerRe: Finding the index of a Listbox item, based on search criteria. VB6 Pin
Richard MacCutchan27-Apr-15 7:04
mveRichard MacCutchan27-Apr-15 7:04 
GeneralRe: Finding the index of a Listbox item, based on search criteria. VB6 Pin
EdwardX227-Apr-15 12:49
EdwardX227-Apr-15 12:49 
GeneralRe: Finding the index of a Listbox item, based on search criteria. VB6 Pin
Sascha Lefèvre27-Apr-15 15:00
professionalSascha Lefèvre27-Apr-15 15:00 
Questionerror when i run my application Pin
Member 1163064825-Apr-15 5:25
Member 1163064825-Apr-15 5:25 
SuggestionRe: error when i run my application Pin
Richard MacCutchan25-Apr-15 6:42
mveRichard MacCutchan25-Apr-15 6:42 
AnswerRe: error when i run my application Pin
Dave Kreskowiak25-Apr-15 10:54
mveDave Kreskowiak25-Apr-15 10:54 
QuestionRun an exe in MDI_Form Pin
bellatriks24-Apr-15 22:35
bellatriks24-Apr-15 22:35 
AnswerRe: Run an exe in MDI_Form Pin
Dave Kreskowiak25-Apr-15 4:06
mveDave Kreskowiak25-Apr-15 4:06 
QuestionPartial public Sub ??? Pin
satc22-Apr-15 9:41
satc22-Apr-15 9:41 
AnswerRe: Partial public Sub ??? Pin
Sascha Lefèvre22-Apr-15 10:16
professionalSascha Lefèvre22-Apr-15 10:16 
QuestionDataGridView.Column("name").DefaultCellStyle.Format applied to all columns (it shouldn't be) Pin
Johan Hakkesteegt22-Apr-15 3:06
Johan Hakkesteegt22-Apr-15 3:06 
Hi,

I have the following method in my (Windows) application to format a report in a DataGridView. The report has a variable amount of columns.
VB
Private Sub FormatColumns(ByVal dgv As DataGridView)
        Try
            For Each clm As DataGridViewColumn In dgv.Columns
                Select Case True
                    Case clm.Name Like "Konserni"
                        'a string value
                        clm.Width = 150
                    Case clm.Name Like "Ketju"
                        'a string value
                        clm.Width = 150
                    Case clm.Name Like "Myyjä"
                        'a string value
                        clm.Width = 150
                    Case clm.Name Like "Myynti"
                        'a monetary value
                        clm.Width = 100
                        clm.DefaultCellStyle.Format = "c"
                    Case clm.Name Like "Budjetti"
                        'a monetary value
                        clm.Width = 100
                        clm.DefaultCellStyle.Format = "c"
                    Case clm.Name.ToLower Like "kate"
                        'a percentage value
                        clm.Width = 120
                        clm.DefaultCellStyle.Format = "P"
                    Case Else
                        clm.Visible = False
                End Select
            Next
        Catch ex As Exception
            EC(ex)
        End Try
    End Sub

When I run the report, and apply this method all columns are formatted as percentages (except the string values of course). It is supposed to format each column differently, depending on the type of value.

What am I doing wrong, or what did I misunderstand about (the use of) DefaultCellStyle ?

Any help appreciated.

Regards,
Johan
My advice is free, and you may get what you paid for.

AnswerRe: DataGridView.Column("name").DefaultCellStyle.Format applied to all columns (it shouldn't be) Pin
Dave Kreskowiak22-Apr-15 4:15
mveDave Kreskowiak22-Apr-15 4:15 
GeneralRe: DataGridView.Column("name").DefaultCellStyle.Format applied to all columns (it shouldn't be) Pin
Johan Hakkesteegt22-Apr-15 20:26
Johan Hakkesteegt22-Apr-15 20:26 
GeneralRe: DataGridView.Column("name").DefaultCellStyle.Format applied to all columns (it shouldn't be) Pin
Johan Hakkesteegt22-Apr-15 21:21
Johan Hakkesteegt22-Apr-15 21:21 
GeneralRe: DataGridView.Column("name").DefaultCellStyle.Format applied to all columns (it shouldn't be) Pin
Dave Kreskowiak23-Apr-15 2:20
mveDave Kreskowiak23-Apr-15 2:20 
GeneralRe: DataGridView.Column("name").DefaultCellStyle.Format applied to all columns (it shouldn't be) Pin
Johan Hakkesteegt23-Apr-15 3:46
Johan Hakkesteegt23-Apr-15 3:46 
GeneralRe: DataGridView.Column("name").DefaultCellStyle.Format applied to all columns (it shouldn't be) Pin
Dave Kreskowiak23-Apr-15 4:05
mveDave Kreskowiak23-Apr-15 4:05 
GeneralRe: DataGridView.Column("name").DefaultCellStyle.Format applied to all columns (it shouldn't be) Pin
Johan Hakkesteegt23-Apr-15 22:21
Johan Hakkesteegt23-Apr-15 22:21 
GeneralRe: DataGridView.Column("name").DefaultCellStyle.Format applied to all columns (it shouldn't be) Pin
Dave Kreskowiak24-Apr-15 3:49
mveDave Kreskowiak24-Apr-15 3:49 
GeneralRe: DataGridView.Column("name").DefaultCellStyle.Format applied to all columns (it shouldn't be) Pin
Johan Hakkesteegt24-Apr-15 4:03
Johan Hakkesteegt24-Apr-15 4:03 
AnswerRe: DataGridView.Column("name").DefaultCellStyle.Format applied to all columns (it shouldn't be) Pin
Eddy Vluggen22-Apr-15 4:51
professionalEddy Vluggen22-Apr-15 4:51 
GeneralRe: DataGridView.Column("name").DefaultCellStyle.Format applied to all columns (it shouldn't be) Pin
Johan Hakkesteegt22-Apr-15 20:31
Johan Hakkesteegt22-Apr-15 20:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.