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. Image for the cookie policy date

Change styles of controls within a GridCell

Hi,

I got a GridControl with a MonthCalendar cell in it. Using VS2005 -VB.NET- with Syncfusion 4.4.0.51 .

1) How can I change the MonthCalendar's HeaderStartColor property (and other properties) that is in a Grid control's cell?

2) Would the same apply to other controls within the Grid, such as a ProgressBar cell?

Thank you.

7 Replies

HA haneefm Syncfusion Team April 27, 2007 10:13 PM UTC

Hi,

1) How can I change the MonthCalendar's HeaderStartColor property (and other properties) that is in a Grid control's cell?

>>>>
One way you can do this by hanlding the CurrentCellShowingDropDown event of the grid and change the TitleBackColor of the MonthCalendar control in a grid. Here is a code snippet.

private void gridDataBoundGrid1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
GridDataBoundGrid grid = sender as GridDataBoundGrid ;
GridDropDownMonthCalendarCellRenderer cr = grid.CurrentCell.Renderer as GridDropDownMonthCalendarCellRenderer;
if( cr != null )
{
foreach(Control c in cr.DropDownContainer.Controls )
{
if( c is MonthCalendar )
{
MonthCalendar calendar = c as MonthCalendar;
calendar.TitleBackColor = Color.Red;
break;
}
}
}
}

2) Would the same apply to other controls within the Grid, such as a ProgressBar cell?

>>>>
The progressBar browser sample will illustrate how you can use ProgressBars in grid cells. In Addition to the properties like Maximum and Minimum, you can also specify properties like Gradient Colors and Images. In addition, this sample will allow you to display an event log which, will show the order of the currentcell events that are raised and the values that are in the cell as the events occur. You will be able to see mouse events as well.

Here is a path.
C:\Program Files\Syncfusion\Essential Studio\4.4.0.49\Windows\Grid.Windows\Samples\CellTypes\ProgressBarCells

Best regards,
Haneef


GA Gus Al-Soori April 28, 2007 12:11 AM UTC

Hi Haneef,

Thanks for the example. I have converted it to the equivalent in VB.NET and it worked, but what I'm trying to accomplish is the same but through a button outside of the grid. Therefore I cannot use a grid event as the user will not be clicking on the grid.

I know which cell contains the MonthCalendar, lets say grid(1,1) . From a button click event outside the grid, how would i be able to achieve this? I was not able to find something like "grid(1,1).Controls"

--
For reference, if anyone wants the equivalent of Haneef's code in VB.NET its below:

Private Sub Grid1_CurrentCellShowingDropDown(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridCurrentCellShowingDropDownEventArgs) Handles Grid1.CurrentCellShowingDropDown
Dim cr As GridDropDownMonthCalendarCellRenderer = Grid1.CurrentCell.Renderer
If IsNothing(cr) = False Then
For Each c As Control In cr.DropDownContainer.Controls
If TypeName(c) = "MonthCalendar" Then
Dim calendar As MonthCalendar = c
calendar.TitleBackColor = Color.Coral
End If
Next
End If
End Sub


GA Gus Al-Soori April 28, 2007 08:12 AM UTC

Any idea regarding the above?


HA haneefm Syncfusion Team April 28, 2007 03:19 PM UTC

Hi Greg,

You can try this code snippet to get a month calendar control from button click event(outside of the grid control). Here is a code snippet.

//Button1_click event
GridDropDownMonthCalendarCellRenderer cr = grid.GetCellRenderer(1,1) as GridDropDownMonthCalendarCellRenderer;
if( cr != null )
{
foreach(Control c in cr.DropDownContainer.Controls )
{
if( c is MonthCalendar )
{
MonthCalendar calendar = c as MonthCalendar;
calendar.TitleBackColor = Color.Red;
break;
}
}
}

Best regards,
Haneef


GA Gus Al-Soori April 28, 2007 04:38 PM UTC

Brilliant, works great. Thank you Haneef.


AG Alex Girenko March 6, 2018 03:23 PM UTC

thank you.


AR Arulpriya Ramalingam Syncfusion Team March 7, 2018 11:33 AM UTC

Hi Alex, 
 
Thanks for the update, please let us know whether you need any further assistance. 
 
Regards, 
Arulpriya 


Loader.
Live Chat Icon For mobile
Up arrow icon