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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to add a UserControl to the Column Heder

Thread ID:

Created:

Updated:

Platform:

Replies:

39447 Jan 9,2006 11:49 AM UTC Jan 17,2006 09:44 AM UTC WinForms 7
loading
Tags: GridControl
Vijaya Kumar Reddy
Asked On January 9, 2006 11:49 AM UTC

Hi, I would like to have a user control to be placed inside the column header of a Grid Grouping control. My user control typically contains more than one button and one label to have the header text. The user control should raise the events and will be handled by the hosting windows form. Looking forward some help to achieve this functionality. Thanks in advance. Regards, Vijay

stanleyj [Syncfusion]
Replied On January 9, 2006 01:00 PM UTC

Hi Vijay, Please refer to this thread that deals implementing a cellType in the header cell of GGC and use CellType as Control and place the usercontrol through style.Control. Best regards, Stanley

Vijaya Kumar Reddy
Replied On January 9, 2006 03:46 PM UTC

Stanly, I could able to display my UserControl in one of the column headers, but the button in my UserControl is not catching the click event as the default behaviour of the column header is to sort. I dont need any sorting on this column but the buttons in my UserControl should catch the mouse clicks. Please provide me some help on this. Thanks in advance. Regards, Vijay >Hi Vijay, > >Please refer to this thread that deals implementing a cellType in the header cell of GGC and use CellType as Control and place the usercontrol through style.Control. > >Best regards, >Stanley

stanleyj [Syncfusion]
Replied On January 9, 2006 04:01 PM UTC

Hi Vijay, you need to cancel the sorting of the header cell by handling the TableControlCellClick event. Best regards, Stanley

Vijaya Kumar Reddy
Replied On January 9, 2006 06:31 PM UTC

Stanley, I did as in the referred sample. I am able to avoid sorting, but not able to make it happen to click the individual buttons in my UserControl. My butons in the UserControl should catch the Click event as that will happen when we place it in any other container. I am planning to implement HitTest in my UserControl. Pl help with any otherways of doing this. Thanks in advance. Regards, Vijay. >Hi Vijay, > >you need to cancel the sorting of the header cell by handling the TableControlCellClick event. > >Best regards, >Stanley >

stanleyj [Syncfusion]
Replied On January 10, 2006 04:59 AM UTC

Hi Vijay, Referring to the sample mentioned earlier. In the TableControl.MouseUp event handler the CellRenderer’s mouseup has to be raised. By default the selectcells mousecontroller calls the Cellrenderer’s MouseUp which in turn raises the checkboxclick. The DragGroupHeader mousecontroller which is for the header cells, doesn’t call the Renderer’s mouseup. So you have to explicitly call the Renderer’s Mouseup from the TableControl’s Mouseup checking for the MouseController type. So if Renderer’s Mouseup is raised then the UserControl would be interactive. Best regards, Stanley

Vijaya Kumar Reddy
Replied On January 10, 2006 11:45 AM UTC

Stanley, Here is the code I written to make the UserControl in the column header, by which I am not able to call my buttons click in my UserControl. 1. I created a UserControl with two buttons with button click handlers. 2. I added the CellModel As Follows. MyGGC.TableModel.CellModels.Add("MyUserControlCell", new MyUserControlCellModel(MyGGC.TableModel.Model)); 3. Added the following code in QueryCellStyleInfo to set the CellType. if ( (style.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell) && (styleColumnName == “MySpecialColumn”)) { style.CellType = "MyUserControlCell"; e.Style.CellAppearance = GridCellAppearance.Raised; e.Handled = true; } 4. Added the following code in TableControlCellClick event handler to avoid sorting on the column. GridTableCellStyleInfo style = e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex]; e.TableControl.TableDescriptor.ColumnToRowColIndex(ModelUpdater.ContactPrimaryPhoneColumnName, out row, out col); if(style.TableCellIdentity.TableCellType == GridTableCellType.ColumnHeaderCell && e.Inner.ColIndex == col) { e.Inner.Cancel = true; } 5. Added the following code in the MouseUp event to allow my UserCOntrol to handle the individual button click. (The Problem area) int row, col; this.MyGGC.TableControl.PointToRowCol(new Point(e.X, e.Y), out row, out col); GridTableCellStyleInfo style = this.MyGGC.TableControl.Model[row, col]; IMouseController controller; this.MyGGC.TableControl.MouseControllerDispatcher.HitTest(new Point(e.X, e.Y), e.Button, e.Clicks, out controller); //if(controller.Name == "MouseController") if(controller.Name == "DragGroupHeader") { this.MyGGC.TableControl.GetCellRenderer(row, col).RaiseMouseUp(row,col,e); } In this Method I always get the Controller as “DragGroupHeader”. As you mentioned I am not able to get the Proper controller to call the MouseUp event. Please provide me a sample to have a user control with more than one button to be used in the column header. I am continuing to understand the other possible concepts. Your help is highly appreciated. Regards, Vijay. >Hi Vijay, > >Referring to the sample mentioned earlier. >In the TableControl.MouseUp event handler the CellRenderer’s mouseup has to be raised. By default the selectcells mousecontroller calls the Cellrenderer’s MouseUp which in turn raises the checkboxclick. The DragGroupHeader mousecontroller which is for the header cells, doesn’t call the Renderer’s mouseup. So you have to explicitly call the Renderer’s Mouseup from the TableControl’s Mouseup checking for the MouseController type. > >So if Renderer’s Mouseup is raised then the UserControl would be interactive. > >Best regards, >Stanley

stanleyj [Syncfusion]
Replied On January 17, 2006 09:44 AM UTC

Hi Vijay, I am sorry for the inconvenience caused. Please refer the attached sample that has an user control in the header cell of the GGC. Best regards, Stanley

Forum_39447.zip

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

;