This is a migrated thread and some comments may be shown as answers.

Creating a Custom RadGridView control

4 Answers 215 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Mark asked on 27 Apr 2017, 03:42 PM

I have my own Grid Class based off of a RadGridView control, because I use the same formatting/settings in multiple places.  When I drag my grid to my form, everything seems fine, but when I add data to it, nothing is formatted.  The ROWS/COLUMNS have no formatting, no grid lines, etc. Not sure what I am doing wrong here.  Any help would be greatly appreciated. 

 

   public  class NtsRadGridView : RadGridView
   {
      #region Public Constructors
 
      public NtsRadGridView()
      {
         MasterTemplate.AllowAddNewRow = false;
         MasterTemplate.AllowCellContextMenu = false;
         MasterTemplate.AllowColumnChooser = false;
         MasterTemplate.AllowColumnHeaderContextMenu = false;
         MasterTemplate.AllowDeleteRow = false;
         MasterTemplate.AllowDragToGroup = false;
         MasterTemplate.AllowEditRow = false;
         MasterTemplate.AllowRowHeaderContextMenu = false;
         MasterTemplate.AllowRowResize = false;
         MasterTemplate.AllowSearchRow = true;
         MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
         MasterTemplate.ViewDefinition = new TableViewDefinition();
         ShowGroupPanel = false;
      }
}

4 Answers, 1 is accepted

Sort by
0
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
answered on 27 Apr 2017, 04:13 PM

Ok, I figured it out, I had to add a public override to the ThemeClassName property.  Once I did this, everything is working as it should be.

 

 

public override string ThemeClassName => typeof(RadGridView).FullName;
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 28 Apr 2017, 07:53 AM
Hello Mark, 

Thank you for writing.  

I am glad that the problem you were facing is now resolved. The following help article is quite useful on this topic: http://docs.telerik.com/devtools/winforms/telerik-presentation-framework/inherit-themes-from-radcontrols-derivatives

I hope this information helps. Should you have further questions I would be glad to help.

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
answered on 28 Apr 2017, 11:41 AM
I saw, from the link you posted, that this should be done for all derived controls.  I have other custom controls that are derived from Telerik controls, ie TextBox, MaskedEditBox, radSplitContainer, etc.and have not experienced the THEME issues like I did with my custom grid derived from the RadGridView.  Howerver, I can see how this should be a best practice.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 01 May 2017, 10:58 AM
Hello Mark, 

Thank you for writing back. 

Note that all controls in the Telerik UI for WinForms suite have their own style applied to the different elements of the structure of the internal elements. That is why in some controls you may not notice problems with the visual appearance at first sight.

If you have any additional questions, please let me know. 

Regards,
Dess
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Answers by
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or