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.

How to change text/styling in row headers

Thread ID:

Created:

Updated:

Platform:

Replies:

80014 Mar 6,2009 01:33 PM Mar 10,2009 01:29 AM Windows Forms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 6, 2009 01:33 PM

Hello,

I am using the GridDataBoundGrid control on a current project of mine. By default, the first column on the control (column 0) shows a little black triangle pointing to the row, when a row receives focus. I would like to change this.

Currently on my grid control, I have a ContextMenu on (column 0) for each row that is loaded. The ContextMenu is working just fine, however there is no indication to the user that is is there. I would like to put my own text on the row header (column 0) to let the user know they can click the row header to get more options, however all my attempts to do this are failing.

I have tried the following 2 events:
GridDataBoundGrid.PrepareViewStyleInfo() and GridDataBoundGrid.CellDrawn().

The following is the code:
private void gridVE_CellDrawn(object sender, GridDrawCellEventArgs e)
{
if (e.ColIndex == 0 && e.RowIndex != 0)
{
e.Style.Text = @"+ / -";
}
}

private void gridVE_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if (e.ColIndex == 0 && e.RowIndex != 0)
{
e.Style.Text = @"+ / -";
}
}

As I have stepped through the PrepareViewStyleInfo event, for some reason the Column Index never = 0, and so that method doesn't work.
As I have stepped through the CellDrawn event, the Column Index does hit 0, and the IF statement is entered, but the resulting grid control that is rendered does not show the text in the row headers.

Please advise as to what I am doing wrong.

Regards,

Pete


Rajadurai C [Syncfusion]
Replied On March 9, 2009 01:18 AM

Hi Pete,

Thanks for your interest in Syncfusion products.

To set custom text in rowheader and remove the black triangle(current row indicator) in griddataboundgrid, please try to set the celltype of rowheader as "Header".

Please refer to the following code handled in PrepareViewStyleInfo event

this.gridDataBoundGrid1.PrepareViewStyleInfo += new Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventHandler(gridDataBoundGrid1_PrepareViewStyleInfo);

void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex > 0 && e.ColIndex == 0)
{
e.Style.CellType = "Header";
e.Style.Text = "Click";
}
}



Regards,
Rajadurai


Administrator [Syncfusion]
Replied On March 9, 2009 10:04 AM

Thank you!

if (e.RowIndex > 0 && e.ColIndex == 0)
{
e.Style.CellType = "Header";
e.Style.Text = "Click";
}

Above code was the piece I was missing.


Rajadurai C [Syncfusion]
Replied On March 10, 2009 01:29 AM

Hi Pete,

Thanks for your update.

Regards,
Rajadurai


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.

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.

;