title: Display user control in DatagridViewCell
body: <p>Winforms .NET 3.5 (C#)</p>
  
  <p>I have a DataGridView (DGView) and I created CustomColumn and CustomCell to be displayed in the DGView. I created a CustomUserControl which I want to display in the CustomCell. </p>
  
  <p>Problem: I don't see the user control in the column. I think I need to override Paint() method in CustomCell - Any points how can I do that ? </p>
  
  <p>Note - MSDN example of hosting user control is for editing the cell value - where you make your user control visible right where you are editing your cell. I want my user control to render as a normal winform control. This user control shows notifications for the row .. and each row can have different notifications. I want users to be able to click on notification and get more details about it. .. but for now I am stuck at "how do I display this user control"</p>
  
  <p>Any pointers will be highly appreciated. </p>
  
  <pre><code> public class CustomColumn : DataGridViewColumn {
      public CustomColumn() : base(new CustomeCell()) { }
      public override DataGridViewCell CellTemplate
      {
          get
          {
              return base.CellTemplate;
          }
          set
          {
              // Ensure that the cell used for the template is a CalendarCell.
              if (value != null &amp;&amp;
                  !value.GetType().IsAssignableFrom(typeof(CustomeCell)))
              {
                  throw new InvalidCastException("It should be a custom Cell");
              }
              base.CellTemplate = value;
          }
      }
  }
  public class CustomeCell : DataGridViewTextBoxCell
  {
      public CustomeCell() : base() { }
      public override Type ValueType
      {
          get
          {
              return typeof(CustomUserControl);
          }
      }
      public override Type FormattedValueType
      {
          get
          {
              return typeof(CustomUserControl);
          }
      }
  }
  </code></pre>