This is a migrated thread and some comments may be shown as answers.

RadGridView column header text

6 Answers 194 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Stefano Zambonin
Top achievements
Rank 1
Stefano Zambonin asked on 06 Aug 2009, 11:27 AM
After populating RadGridView with AutoGenerateColumns = true i try to change the column header text:

RGVBBoxRecords.Columns[idx].HeaderText = headerstr[idx];
or
RGVBBoxRecords.Columns[idx].Header = headerstr[idx];

but nothing changes.

How to do it?

 

6 Answers, 1 is accepted

Sort by
0
Allan
Top achievements
Rank 1
answered on 06 Aug 2009, 11:40 AM
I have the same problem using Radcontrols for WPF v. 2009.2.701.35.

My code uses a dictionary as resource and dynamicresource to bind to it.

            <Controls:RadGridView.Columns>
                <Controls:GridViewDataColumn HeaderText="{DynamicResource WindowMain_RadGridViewCustomers_CompanyName}" UniqueName="CompanyName" />
            </Controls:RadGridView.Columns>

Any solutions to this problem or do i need to reinstall the previous version where the problem doesn't exist?




0
Missing User
answered on 06 Aug 2009, 01:16 PM

Hello,

@ Allan:
With our Q2 2009 we introduced new column property Header (of type object)  similar to MS DataGrid and now HeaderText is obsoleted.

@Stefano Zambonin:
You may try to subscribe to the DataLoaded event of the RadGridView and  perform updates to the desired column header like this:

void gridview_DataLoaded(object sender, EventArgs e)
        {
            this.RadGridView1.Columns[0].Header = "Test1";
        }

Hope this helps.

Best wishes,

Anastasia
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Stefano Zambonin
Top achievements
Rank 1
answered on 06 Aug 2009, 01:23 PM
Exactly what i'm doing:

 

void RGVBBoxRecords_DataLoaded(object sender, EventArgs e)

 

{

 

  for (int idx = 0; idx < RGVBBoxRecords.Columns.Count; ++idx)

 

  {

 

    if (idx < headerstr.Count)

 

    {

    RGVBBoxRecords.Columns[idx].Header = headerstr[idx];

    }

  }

.......

and in fact watching with debugger i can see that the Header field is setup properly but nothing happens really: on the screen there are the old strings.
0
Allan
Top achievements
Rank 1
answered on 06 Aug 2009, 01:40 PM
That did the trick... :) That should teach me a lesson, but I can't seem to remember what? :p Could it be something with changes since last version?

Thanks alot for the quick response...

0
Missing User
answered on 06 Aug 2009, 02:56 PM

Hi Stefano Zambonin,


Unfortunatelly I couldn't reporoduce the described problem with our official 2009Q2 binaries. Can you please tell us which version of our controls are you using?

However a possible workaround is to subscribe to the AutoGeneratingColumn event:

 void RGVBBoxRecords_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e)  
        {  
              e.Column.Header = headerstr[counter];  
              counter++;  
        } 

Please find attached a simple application.

Greetings,

Anastasia
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Stefano Zambonin
Top achievements
Rank 1
answered on 06 Aug 2009, 04:11 PM

Ok, this way works but if possible i would prefer to use the other way (cleaner code).

I'm using 1 july Q9 2009 version.

 

Stefano Zambonin

Risorse Informatiche srl

Tags
GridView
Asked by
Stefano Zambonin
Top achievements
Rank 1
Answers by
Allan
Top achievements
Rank 1
Missing User
Stefano Zambonin
Top achievements
Rank 1
Share this question
or