Link to home
Create AccountLog in
Avatar of moosetracker
moosetracker

asked on

changing the HeaderText of datagrid not working

I am trying to programically change the HeaderText of the datagrid. My code doesn't blow up and if you display the code in debug, before the code it has the original text, after the headertext is changed..

But...   the change does not display on the form in runtime.. What am I doing wrong.

        If cbUnitType.SelectedIndex > -1 Then
            If rbMeritBadge.Checked = True Then
                If cbUnitType.SelectedItem = "Troop" Or cbUnitType.SelectedItem = "Crew" Then
                    setAwardType = "MB"
                    rbMeritBadge.Text = "Merit Badge"
                    dgMeritBadgetkn.Columns(0).HeaderText = "Merit Badge"
                Else
                    setAwardType = "AP"
                    rbMeritBadge.Text = "Activity Pins"
                    dgMeritBadgetkn.Columns(0).HeaderText = "Activity Pin"
                End If
            ElseIf rbRank.Checked = True Then
                dgMeritBadgetkn.Columns(0).HeaderText = "Rank"
                If cbUnitType.SelectedItem = "Troop" Then
                    setAwardType = "BR"
                ElseIf cbUnitType.SelectedItem = "Pack" Then
                    setAwardType = "CR"
                ElseIf cbUnitType.SelectedItem = "Crew" Then
                    setAwardType = "VR"
                End If
            ElseIf rbAward.Checked = True Then
                dgMeritBadgetkn.Columns(0).HeaderText = "Award"
                If cbUnitType.SelectedItem = "Troop" Then
                    setAwardType = "BA"
                ElseIf cbUnitType.SelectedItem = "Pack" Then
                    setAwardType = "CA"
                ElseIf cbUnitType.SelectedItem = "Crew" Then
                    setAwardType = "VA"
                End If
            End If
        End If
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Is it datagridview? Is it data bound?
Avatar of moosetracker
moosetracker

ASKER

Sorry.. This is a datagridview..
And is it databound? If so, change the name of the columns in datatable before binding.
Other fields in the datagrid are datbound.. But this one is not. That is because the table has a code, and I pull the description & load it...

I tried doing a dataset of  both tables, with a key link, but the datagridview still only wanted to use only 1 of the tables.. I didn't want to create an SP either, so I unbound this column and fill it on the fly..
Why dont you add this column to the datatable and fill it?
Can this be done at the dataset, not in the actual table??  Anyway I don't think it will solve my problem, since I don't want to make 4 different tables.. The dataset is all the records, then if filtered one way the title over this  discription will read one thing, filtered another this title will read something else and it will split into Merit Badge, Activity pin, Rank or Award..

Since you have no sugestion about how to get the Headertext to work,  I take that this textheader field has a bug in it, and does not work as it should. Is this correct?
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Well the grid doesn't work, but I guess this will.. Changing the grid column title would be easier & cleaner then doing all this in order to change a title column header name