Solved

changing the HeaderText of datagrid not working

Posted on 2010-11-14
8
499 Views
Last Modified: 2012-05-10
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
0
Comment
Question by:moosetracker
  • 4
  • 4
8 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34131179
Is it datagridview? Is it data bound?
0
 
LVL 1

Author Comment

by:moosetracker
ID: 34131738
Sorry.. This is a datagridview..
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34131878
And is it databound? If so, change the name of the columns in datatable before binding.
0
 
LVL 1

Author Comment

by:moosetracker
ID: 34131905
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..
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 83

Expert Comment

by:CodeCruiser
ID: 34131940
Why dont you add this column to the datatable and fill it?
0
 
LVL 1

Author Comment

by:moosetracker
ID: 34132171
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?
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 34132209
When I say DataTable, I mean the table inside the dataset(dataset is a collection of datatables).

You can create dataview objects from the datatables similar to views in databases

http://msdn.microsoft.com/en-us/library/8sd1cd0a.aspx


I dont think its a bug in grid. Try calling the Refresh function after changing header.
0
 
LVL 1

Author Closing Comment

by:moosetracker
ID: 34179489
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
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now