CellType = "GridListControl" for GridControl

HI

I am using the GridControl. I have set the cell type of a particular cell as GridListControl.

The datasource of the gridlistcontrol is a List which in turn has been populated buy iterating thru a datareader.

I need to do the following

1. Change the column headings that i am getting in the dropdown gridlist.

2. I need to optionally hide some columns and not have them displayed in the dropdown GridListControl

I am writing this in a hurry and do hope i have been clear enough.

Any clarifications just get in touch

Thanks a Ton in advance


5 Replies

SA Saravanan A Syncfusion Team March 26, 2007 05:47 PM UTC

Hi RH,

1, Change the column headings that i am getting in the dropdown gridlist.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

This can be achieved by changing the cellvalues of the header cells. For this, PrepareViewStyleInfo event of the underlying gridcontrol can be used.
Here is the code snippet.
//In form load
GridDropDownGridListControlCellRenderer renderer = this.gridControl1.CellRenderers["GridListControl"] as GridDropDownGridListControlCellRenderer;
renderer.ListControlPart.Grid.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(Grid_PrepareViewStyleInfo);
..
void Grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex == 0)
{
if (e.Style.CellValue.ToString() == "col2")
{
e.Style.CellValue = "Column2";
}
}
}

2, I need to optionally hide some columns
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Any columns of gridlistcontrol celltype in gridcontrol can be made hidden from the ''CurrentCellShowingDropDown'' Event of gridcontrol.
Here is the code snippets.
void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
GridDropDownGridListControlCellRenderer renderer = cc.Renderer as GridDropDownGridListControlCellRenderer;
if (renderer != null)
{
renderer.ListControlPart.Grid.HideCols["columnName"] = true;
}
}

Regards,
Saravanan


RH Rahul Hans March 27, 2007 05:32 AM UTC

HI Saravanan

Thanks ! This solves two remaining issues...

It also gives me sufficient inputs to try to solve some more issues which have come up in the meanwhile

>Hi RH,

1, Change the column headings that i am getting in the dropdown gridlist.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

This can be achieved by changing the cellvalues of the header cells. For this, PrepareViewStyleInfo event of the underlying gridcontrol can be used.
Here is the code snippet.
//In form load
GridDropDownGridListControlCellRenderer renderer = this.gridControl1.CellRenderers["GridListControl"] as GridDropDownGridListControlCellRenderer;
renderer.ListControlPart.Grid.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(Grid_PrepareViewStyleInfo);
..
void Grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex == 0)
{
if (e.Style.CellValue.ToString() == "col2")
{
e.Style.CellValue = "Column2";
}
}
}

2, I need to optionally hide some columns
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Any columns of gridlistcontrol celltype in gridcontrol can be made hidden from the 'CurrentCellShowingDropDown' Event of gridcontrol.
Here is the code snippets.
void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
GridDropDownGridListControlCellRenderer renderer = cc.Renderer as GridDropDownGridListControlCellRenderer;
if (renderer != null)
{
renderer.ListControlPart.Grid.HideCols["columnName"] = true;
}
}

Regards,
Saravanan


RH Rahul Hans March 27, 2007 07:55 AM UTC

Hi Saravanan

I need to have some control over the order of columns that appear in the GridListControl.

At the moment I am not able to find out on what basis does the GridListcontrol order the columns.

Just to refresh your memory I am using Gridlistcontrol as a celltype in the gridcontrol.

The datasource is a list which is populated thru a datareader.

I read some in the forumn that deriving gridlistcontrol and overriding CreateGridColumn should do the job, but that isnt working out for me.

Your previous advice helped a lot. I was also able to align and format the columns.

One more thing. How does one access in code the row selected in the GridListControl.

Thanks & Best Regards
RH



>HI Saravanan

Thanks ! This solves two remaining issues...

It also gives me sufficient inputs to try to solve some more issues which have come up in the meanwhile

>Hi RH,

1, Change the column headings that i am getting in the dropdown gridlist.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

This can be achieved by changing the cellvalues of the header cells. For this, PrepareViewStyleInfo event of the underlying gridcontrol can be used.
Here is the code snippet.
//In form load
GridDropDownGridListControlCellRenderer renderer = this.gridControl1.CellRenderers["GridListControl"] as GridDropDownGridListControlCellRenderer;
renderer.ListControlPart.Grid.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(Grid_PrepareViewStyleInfo);
..
void Grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex == 0)
{
if (e.Style.CellValue.ToString() == "col2")
{
e.Style.CellValue = "Column2";
}
}
}

2, I need to optionally hide some columns
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Any columns of gridlistcontrol celltype in gridcontrol can be made hidden from the 'CurrentCellShowingDropDown' Event of gridcontrol.
Here is the code snippets.
void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
GridDropDownGridListControlCellRenderer renderer = cc.Renderer as GridDropDownGridListControlCellRenderer;
if (renderer != null)
{
renderer.ListControlPart.Grid.HideCols["columnName"] = true;
}
}

Regards,
Saravanan


RH Rahul Hans March 27, 2007 07:55 AM UTC

Hi Saravanan

I need to have some control over the order of columns that appear in the GridListControl.

At the moment I am not able to find out on what basis does the GridListcontrol order the columns.

Just to refresh your memory I am using Gridlistcontrol as a celltype in the gridcontrol.

The datasource is a list which is populated thru a datareader.

I read some in the forumn that deriving gridlistcontrol and overriding CreateGridColumn should do the job, but that isnt working out for me.

Your previous advice helped a lot. I was also able to align and format the columns.

One more thing. How does one access in code the row selected in the GridListControl.

Thanks & Best Regards
RH



>HI Saravanan

Thanks ! This solves two remaining issues...

It also gives me sufficient inputs to try to solve some more issues which have come up in the meanwhile

>Hi RH,

1, Change the column headings that i am getting in the dropdown gridlist.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

This can be achieved by changing the cellvalues of the header cells. For this, PrepareViewStyleInfo event of the underlying gridcontrol can be used.
Here is the code snippet.
//In form load
GridDropDownGridListControlCellRenderer renderer = this.gridControl1.CellRenderers["GridListControl"] as GridDropDownGridListControlCellRenderer;
renderer.ListControlPart.Grid.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(Grid_PrepareViewStyleInfo);
..
void Grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if (e.RowIndex == 0)
{
if (e.Style.CellValue.ToString() == "col2")
{
e.Style.CellValue = "Column2";
}
}
}

2, I need to optionally hide some columns
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Any columns of gridlistcontrol celltype in gridcontrol can be made hidden from the 'CurrentCellShowingDropDown' Event of gridcontrol.
Here is the code snippets.
void gridControl1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
GridCurrentCell cc = this.gridControl1.CurrentCell;
GridDropDownGridListControlCellRenderer renderer = cc.Renderer as GridDropDownGridListControlCellRenderer;
if (renderer != null)
{
renderer.ListControlPart.Grid.HideCols["columnName"] = true;
}
}

Regards,
Saravanan


RA Rajagopal Syncfusion Team March 27, 2007 05:37 PM UTC

Hi RH,

Your other forum thread with a similar query has been updated. Please followup there for any further queries.
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=58736

Thanks for using Syncfusion Products.
Regards,
Rajagopal

Loader.
Up arrow icon