Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to save the property of the user-defined column ?

How to save the property of the user-defined column ?

Scheduled Pinned Locked Moved C#
tutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mctramp168
    wrote on last edited by
    #1

    public class TXDataGridViewNumericColumn : DataGridViewColumn { public TXDataGridViewNumericColumn() : base(new TXNumericCell()) { this.InputType = NumericType.Integer; } public override DataGridViewCell CellTemplate { get { return base.CellTemplate; } set { if (value != null && !value.GetType().IsAssignableFrom(typeof(TXNumericCell))) { throw new InvalidCastException("Must be a CalendarCell"); } base.CellTemplate = value; } } private NumericType m_NumericType; public enum NumericType { Decimal, Integer, PositiveDecimal, NegativeDecimal, PositiveInteger, NegativeInteger } public NumericType InputType { get { return m_NumericType; } set { m_NumericType = value; } } public ICollection testCollection { get { return Icollection; } set { Icollection = value; } } private ICollection Icollection; public override object Clone() { DataGridViewColumn col = (DataGridViewColumn)base.Clone(); col.CellTemplate = new TXNumericCell(); return col; } } public class TXNumericCell : DataGridViewTextBoxCell { public TXNumericCell() : base() { } public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle) { base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle); TXNumericEditControl ctl = DataGridView.EditingControl as TXNumericEditControl ; ctl.Text = (string )this.Value; } public override Type EditType { get { return typeof(TXNumericEditControl); } } public override Type ValueType { get { return typeof(string); } } public override object DefaultNewRowValu

    N 1 Reply Last reply
    0
    • M mctramp168

      public class TXDataGridViewNumericColumn : DataGridViewColumn { public TXDataGridViewNumericColumn() : base(new TXNumericCell()) { this.InputType = NumericType.Integer; } public override DataGridViewCell CellTemplate { get { return base.CellTemplate; } set { if (value != null && !value.GetType().IsAssignableFrom(typeof(TXNumericCell))) { throw new InvalidCastException("Must be a CalendarCell"); } base.CellTemplate = value; } } private NumericType m_NumericType; public enum NumericType { Decimal, Integer, PositiveDecimal, NegativeDecimal, PositiveInteger, NegativeInteger } public NumericType InputType { get { return m_NumericType; } set { m_NumericType = value; } } public ICollection testCollection { get { return Icollection; } set { Icollection = value; } } private ICollection Icollection; public override object Clone() { DataGridViewColumn col = (DataGridViewColumn)base.Clone(); col.CellTemplate = new TXNumericCell(); return col; } } public class TXNumericCell : DataGridViewTextBoxCell { public TXNumericCell() : base() { } public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle) { base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle); TXNumericEditControl ctl = DataGridView.EditingControl as TXNumericEditControl ; ctl.Text = (string )this.Value; } public override Type EditType { get { return typeof(TXNumericEditControl); } } public override Type ValueType { get { return typeof(string); } } public override object DefaultNewRowValu

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      No one will read such a long post. Don't dump all your code. Please modify your post and put only the code that is relevant and wrap it inside <pre></pre> tags so that CP will format it. :)

      Navaneeth How to use google | Ask smart questions

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups