Solved

changing the HeaderText of datagrid not working

Posted on 2010-11-14
8
503 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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
 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 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