caption for databound grid

I was wondering how to set the caption text on a databound grid. I want to set a title or label above my grid without having to use a seperate label. thanks

7 Replies

AD Administrator Syncfusion Team September 25, 2006 05:48 AM UTC

Hi Charlie,

Try setting the Rows.HeaderCount property to add the number of extra header in a grid and also call the CoveredRanges.Add(GridRangeInfo.Row(0)) to make the ZERO th row as covered cell. Below is a code snippet

this.grid.Model.Rows.HeaderCount = 1;

for(int i = 1; i <= this.grid.Model.ColCount;i++)
this.grid.Model[1,i].Text = this.grid.Model[0,i].Text ;

this.grid.Model.CoveredRanges.Add(GridRangeInfo.Row(0));
this.grid.Model[0,0].Text = dt.TableName;

this.grid.ThemesEnabled = true;

Thanks,
Haneef


CM Charlie Mao October 12, 2006 12:06 AM UTC

Hey Haneef,

I tried the below code and the test appears on the top left corner instead of the first row above the grid. Can you help me fix this.

this.dataGridAPS.Model.Rows.HeaderCount = 1;

for(int i = 1; i <= this.dataGridAPS.Model.ColCount;i++)
this.dataGridAPS.Model[1,i].Text = this.dataGridAPS.Model[0,i].Text ;

this.dataGridAPS.Model.CoveredRanges.Add(GridRangeInfo.Row(0));
this.dataGridAPS.Model[0,0].Text = "Proposal A";

Please refer to the picture for clarity.

>Hi Charlie,

Try setting the Rows.HeaderCount property to add the number of extra header in a grid and also call the CoveredRanges.Add(GridRangeInfo.Row(0)) to make the ZERO th row as covered cell. Below is a code snippet

this.grid.Model.Rows.HeaderCount = 1;

for(int i = 1; i <= this.grid.Model.ColCount;i++)
this.grid.Model[1,i].Text = this.grid.Model[0,i].Text ;

this.grid.Model.CoveredRanges.Add(GridRangeInfo.Row(0));
this.grid.Model[0,0].Text = dt.TableName;

this.grid.ThemesEnabled = true;

Thanks,
Haneef

caption.zip


CM Charlie Mao October 13, 2006 05:30 PM UTC

Anyone knows how to set captions to a data bound grid?


AD Administrator Syncfusion Team October 16, 2006 06:44 AM UTC

Hi Charlie,

Please refer to the attached sample for more details.

//It implements the QueryCoveredRange event to manually set the covered range of the cell in a grid.
Sample : http://www.syncfusion.com/Support/user/uploads/GDBGCoveredRange_68674e6b.zip

Let me know if you are looking something different.

Best Regards,
Haneef


CM Charlie Mao October 17, 2006 07:14 PM UTC

Hey Haneef,

This code was very helpful. It worked great. I was wondering if this could be modified a little though. Right now, it is putting the caption on the same row as my heading. I was wondering if the caption can be on one row by itself and then below that would be my 2nd header, then the grid data. I attached a screenshot of what I am getting as of now. Thanks so much.

Charlie

screenshot27.zip


CM Charlie Mao October 17, 2006 07:44 PM UTC

Actually Haneef,

What I am finding is that the caption row when inserted is not pushing my other header down. The screenshot I sent you is with this line commented out:
this.dataGridA.Model.CoveredRanges.Add(GridRangeInfo.Row(0));

When I leave this line in, the caption row appears to show up on top of my header row. Any suggestions???


CM Charlie Mao October 17, 2006 09:38 PM UTC

Hi Haneef,

I think I found out the problem. Thanks for your help.

Charlie

Loader.
Up arrow icon