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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Column Header Text in a GridControl

Thread ID:

Created:

Updated:

Platform:

Replies:

59616 Apr 18,2007 04:16 PM UTC Mar 31,2008 09:40 AM UTC Windows Forms 6
loading
Tags: GridControl
Greg Goodall
Asked On April 18, 2007 04:16 PM UTC

The GridControl by default sets the Column Header's at A, B, C, D etc. I want to give each column my own text such as CustId, AccountNo, CustomerName, AccountBalance.

How can this be done?

Thanks

haneefm [Syncfusion]
Replied On April 18, 2007 05:18 PM UTC

Hi Greg,

You can try this code.

this.gridControl1.PopulateHeaders(GridRangeInfo.Cells(0,1,0,4) ,table);

Best regards,
Haneef

Greg Goodall
Replied On April 18, 2007 06:28 PM UTC

I am using the code below but it only changes the header of the first column from "A" to "Value".

Dim strHeaders() As String
strHeaders = New String() {"CustId", "AccountNo", "CustomerName", "AccountBalance"}
Me.gridMatrixLines.PopulateHeaders(GridRangeInfo.Cells(0, 1, 0, 4), strHeaders)

Do you have an example VB project that I could look at?

Thanks

haneefm [Syncfusion]
Replied On April 18, 2007 07:03 PM UTC

Hi Greg,

You can try this code.

Dim dt As DataTable = New DataTable
dt.Columns.Add("CustId")
dt.Columns.Add("AccountNo")
dt.Columns.Add("CustomerName")
dt.Columns.Add("AccountBalance")
Dim dr As DataRow = dt.NewRow()
dt.Rows.Add(dr)
dt.AcceptChanges()

Me.GridControl1.PopulateHeaders(Syncfusion.Windows.Forms.Grid.GridRangeInfo.Cells(0, 1, 0, 5), dt)

Best regards,
Haneef

Greg Goodall
Replied On April 18, 2007 08:34 PM UTC

This worked perfectly. Now I have to figure out how to set the width of each column based upon the length of the text.

Thanks.

ranjumalhotra
Replied On March 28, 2008 09:53 AM UTC

Hi,

I have retained the deafult column headers.However if i try to retrieve the column header text by saying
string str=this.GridControl1[0,1].Text;
it does not provide any value.

please help.

Thanks
ranju malhotra

>The GridControl by default sets the Column Header's at A, B, C, D etc. I want to give each column my own text such as CustId, AccountNo, CustomerName, AccountBalance.

How can this be done?

Thanks


Administrator [Syncfusion]
Replied On March 31, 2008 09:40 AM UTC


Hi Greg,

Thanks for the interest in Syncfusion products.

You can set the Column header text of the gird from the Text properties and also you can retrieve the column header by saving to a string. Please refer the following code snippet.


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
GridControl1(0, 1).Text = "CustId"
GridControl1(0, 2).Text = "AccountNo"
GridControl1(0, 3).Text = "CustomerName"
GridControl1(0, 4).Text = "AccountBalance"
GridControl1.Model.ColWidths.ResizeToFit(Syncfusion.Windows.Forms.Grid.GridRangeInfo.Col(1))
GridControl1.Model.ColWidths.ResizeToFit(Syncfusion.Windows.Forms.Grid.GridRangeInfo.Col(2))
GridControl1.Model.ColWidths.ResizeToFit(Syncfusion.Windows.Forms.Grid.GridRangeInfo.Col(3))
GridControl1.Model.ColWidths.ResizeToFit(Syncfusion.Windows.Forms.Grid.GridRangeInfo.Col(4))
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim str1 As String = Me.GridControl1(0, 1).Text
Dim str2 As String = Me.GridControl1(0, 2).Text
Dim str3 As String = Me.GridControl1(0, 3).Text
Dim str4 As String = Me.GridControl1(0, 4).Text
MessageBox.Show("Col1: " + str1 + " Col2:" + str2 + " Col3:" + str3 + " Col4 : " + str4)
End Sub


Please refer the sample in the below link that illustrates the above.

http://websamples.syncfusion.com/samples/Grid.Windows/F59616/main.htm

Please let me know if this is not what you needed.

Regards,
Asem.


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.

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

;