We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Setting Column Headers in Databound Grid - No success

Thread ID:

Created:

Updated:

Platform:

Replies:

2953 Feb 23,2003 09:59 PM UTC Feb 24,2003 07:19 PM UTC WinForms 3
loading
Tags: GridControl
Knut Vonheim
Asked On February 23, 2003 09:59 PM UTC

I am trying to set the column headers for a databound grid using gridName[0, 1].Text = "MyColumnHeader"; in C#. It works for gridName[0,0].Text = "Test"; Is this because 0,0 is not databound? If so, what do I need to do to set it for a databound grid? I am on version 1.5.1.6 I think (the lates download patch). I can read the original text though and put it in a messagebox. Thanks, Knut

Knut Vonheim
Replied On February 23, 2003 10:24 PM UTC

I have also tried gridName.GridBoundColumns["ColumnName"].HeaderText = "NewHeader"; gridName.GridBoundColumns[1].HeaderText = "NewHeader"; but get an error message at run time saying: "An unhandled exception of type 'System.NullReferenceException' occurred in ucscheduledaycardio.dll Additional information: Object reference not set to an instance of an object." The problem is that the object and the data that go with it is displayed on the screen. I even tried to put this on a button just to make sure. No luck! The code in the previous posting does not cause an error. Thanks again! Knut

Administrator [Syncfusion]
Replied On February 23, 2003 10:50 PM UTC

You do need to set the header text through the GridBoundColumns. But if you are getting thoses null reference exceptions, it suggests that you did not add any GridBoundColumns to your GridDataBoundGrid. In such a case, you should use the Binder.InternalColumns that are added for you when you don't add any. So, try code such as gridName.Binder.InternalColumns[1].HeaderText = "NewHeader";

Knut Vonheim
Replied On February 24, 2003 07:19 PM UTC

Clay, that worked! I must have been mistaken when I thought the GridBoundColumns were added if I bound a column to a dataset column in the designer. Wish the documentation was a little better, but you and this forum are great alternatives! Thanks again Clay! Cheers, Knut

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;