Windows > Windows Forms Forums > Windows Forms Data Controls and Databinding > New whitepapers for building DataGridView custom cells and columns
Ask a questionAsk a question
 

General DiscussionNew whitepapers for building DataGridView custom cells and columns

All Replies

  • Wednesday, February 22, 2006 12:34 PMSSyed Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    Hi Regis,

    Please help me with this my project requires something similar to the post at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=233259&SiteID=1.

    The post was very help full; can u please give me some more information on how to to place a icon next to the text in a data grid view col;  means the icon and text shud look in same col

    // i am using VS2005; and i m aware of the datagridimage col; but it can only display image;

    i hav tried with many sols provided in web but with not much luck; please help me with this

    what will be the best option

     

    Thanks in advance


     

  • Wednesday, February 22, 2006 1:19 PMSSyed Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi,

     Also is it possible to display a local image in to textboxCell along with the data recevied from a database,

    for eg i want to show a icon based on the status of the record

    As far as i think: i can do it in two ways by storing the icon in sql server or else setting a flag and depending on it changing the icon(choosing frm local resource)

    wats according to u is the best option; which will guarentee the better performance

     

    Thanks in advance;

     

     

     

  • Wednesday, March 08, 2006 3:30 AMTrần Ngọc Văn Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    What if the NumbericUpdown control is disposed?
    MyForm frm = new MyForm();

    void Test()
    {
        frm.ShowDialog();
    }

    void Test2()
    {
        frm = new MyForm()
        frm.Show(); //Error
    }
  • Wednesday, March 15, 2006 6:15 PMMaximeR Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I think I have the same problem.

    I’ve tried incorporating the NumeicUpDown column in a solution.  The first time I show the form containing my DataGridView, it works fine.  Than, I close the form and try to show it a second time, and it crashes here :

    //DataGridViewNumericUpDownCell.cs
    //Line 579

    // Make sure the NumericUpDown control is parented to a visible control

    if
    (paintingNumericUpDown.Parent == null || paintingNumericUpDown.Parent.Visible)
    {
        paintingNumericUpDown.Parent = this.DataGridView; // <==           
    }

     

    It trows a ObjectDisposedException.

    Stangely, I use the NumeicUpDown column on a other form and it works without a glitch.  

  • Friday, March 17, 2006 7:09 AMTrần Ngọc Văn Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    One more problem: When the form containing the DataGridView with NumbericUpdownColumn is disabled and enabled again, the column is still painted in disable, :(
  • Thursday, March 30, 2006 6:47 AMHr_Ind Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
     

    How we can set the default values for those

    editing Control .

    Like By Numberic Updown COlumn i want it starts from 1 or 10

    By date calender Probelm i want to set the start default date.

    How we can achieve this with these Editing Controls

    How we make these Controls Also opens with the keyboard without mouse help

     

     

    Thanks a lot in advance


  • Tuesday, April 04, 2006 11:36 AMMcBain Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    The solution for this exception is very simple. You only have to remove the 'static' modifier at line 54 of DataGridViewNumericUpDownCell.cs

    It worked for me.
  • Tuesday, April 04, 2006 4:00 PMBuster951 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Is it possible for Microsoft to add VB.Net 2005 source code to your white papers:
     
    1) Build A Custom Numeric UpDown Cell and Column For The DataGridView Control
    2) Building A Custom Radiobutton Cell and Column For TheDataGridView Control
     
    I tried to convert the C# code in the article on the RadioButton but did not have any success.
     
    Also, is it possible for the radiobuttons to be horizontal in a cell instead of vertical?

    Thanks in advance,

    Marc
    mbmiller@micropath.com
  • Friday, May 26, 2006 3:50 PMKris Wragg Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Just a quick question, before I start putting time and effort into researching and implementing something.  Is it possible, or more important, is it possible without a LOT of work to implement DataGridViewCell's who's value is something more complex, ie perhaps a class of somesort?

    I'm wanting to create a customizeable view, using the TreeGridView, and then create some cell's that have custom painted graphics to represent various data, for example, one will store and display the last 5 values of an event I will be listening for (its a bit more complex than that but simplist way to explain).  So most likely it will be storing an ArrayList or similar that will store 5 float values.

    One of them will be a lot more complex than that, storing a lot of information for various different things.

    Thanks for any responses :)

    [edit] PS. These won't be user editable, they will be entirely driven by backend data, it will merely be a way for customers to see complex data about service information etc.

  • Friday, June 02, 2006 5:39 AMnkotb Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi Regis,

    Do you have the sample code of DataGridViewNumericUpDown in vb.net?

    thanks you

  • Sunday, June 04, 2006 2:28 AMdave.t Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi Regis,

    Will a c++ example added soon? Or can you point to a c++ example that uses a class derived from an interface class in visual c++ 2005. Thanks

    Regards

    dave.t 

  • Tuesday, June 06, 2006 10:03 AMnkotb Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi Buster95,

    did you manage to get the DataGridViewNumericUpDown in vb.net 2005?

    Can i have it?

    Thanks you

  • Thursday, June 08, 2006 12:51 PMCara2006 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi,

    Does someone has the source code in VB.Net 2005 to these two white papers?

    1) Build A Custom Numeric UpDown Cell and Column For The DataGridView Control
    2) Building A Custom Radiobutton Cell and Column For TheDataGridView Control
     
    If so, can you send it to cara2006@sapo.pt, please?
     
    Thanks
    Cara
     
     
     
  • Tuesday, July 11, 2006 6:00 PMBluehunter Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

       I'm using the CalenderColumn provided from MSDN with the address http://msdn2.microsoft.com/en-us/library/7tas5c80.aspx#Mtps_DropDownFilterText

    the problem is that when I want to validate to datetime fields using CalenderColumn from RowValidating event of the datagridview, I get stucked. I validate if two datetime fields have a day difference of 1.

    TimeSpan diff = seconddate.Subtract(firstdate);

    if( diff.Days  < 1)

    {

       MessageBox.Show("Second date must be greater that first date");

       e.Cancel = true;

    }

    please try it yourself and see the result. Any idea?

  • Thursday, August 03, 2006 2:55 AMBob5461 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I am also looking for an UpDown Column to be used in VB 2005. I see a number of posts but no replies on this forumn. Could some one be kind enough to help. Thanks Bob5461
  • Friday, August 04, 2006 12:58 AMBoorKing Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I want to add an checkbox control on the headerCell of DataGridView.how can I do it.Override Paint? if it's right but the event whether will be disappear?
  • Wednesday, August 16, 2006 4:45 PMMWSDBA Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Regis -- great work on the custom DataGridView columns.

    Any chance you'll be doing a Rich Text Format column any time soon?


    I'm currently in need of a read only RTF cell control for the DGV.  I have about 9 distinct pieces to shove in a single cell.  I suppose I could use 9 text box controls and attempt to hide the box lines (so that 9 boxes look like one) but RTF would provide a much nicer way of doing things.

    Another option would be to wrap Excel functionality into this but I'd rather not......


    Thanks
  • Thursday, August 17, 2006 6:07 AMBluehunter Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

     

                 NumericUpDown cell throws ObjectDisposed Exception! Has anybody met the same prblem?

  • Wednesday, December 13, 2006 4:15 PMJesArg Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    The sample code has a problem. 

    If the DataGridView with the NumericUpDown column is on an MDI child form, then it will display correctly the first time the MDI child form is displayed in the MDI container.  However, if the MDI child form is closed and then re-opened in the MDI container, then the DataGridView will fail to paint cells (starting with the first NumericUpDownCell).


  • Wednesday, March 14, 2007 10:05 AMUlliDK Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Did you find a solution to this? I'm experiencing the exact same problem:(
  • Wednesday, March 14, 2007 7:38 PMJesArg Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I never figured out what caused the problem, but I did sort of find a way around it.  If you just follow the example on http://msdn2.microsoft.com/en-us/library/7tas5c80.aspx to make custom column types, it seems to work.  I'm sure there's some minor difference between that example and the NumericUpDown example, but I never ended up taking the time to figure out what.

    Furthermore, vendors (such as Infragistics) have implemented custom column types for the DataGridView control that have no issues with the MDI container, too.  These cost money, though.  Of course, you might already have these if you already have a license to their WinForms suite.


  • Friday, May 18, 2007 3:05 AMBob5461 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Try here for NumericUpDown control in dgv

    http://www.knowdotnet.com/articles/kdngrid.html

  • Friday, May 18, 2007 3:06 AMBob5461 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
  • Friday, May 18, 2007 3:07 AMBob5461 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
  • Monday, July 09, 2007 1:54 PMShahidHameed2 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    hi

    i create my own customized datagrid columns and thy are working fine if i use them with in code

    but customized columns types are not listed in design time when i add new column

    can any body help me??????????????????????????

    thanks

  • Friday, July 27, 2007 5:01 PMJoshL Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    The links above are now broken - are these whitepapers still availalbe?

     

    Thanks!

     

    - Josh

  • Tuesday, November 20, 2007 8:05 PMbluejack Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Removing the static modifier worked for me also thaks
    [ThreadStatic]
    private static NumericUpDown paintingNumericUpDown;
  • Tuesday, November 20, 2007 8:07 PMbluejack Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Yes I found one at
    http://msdn2.microsoft.com/en-us/library/aa730881(vs.80).aspx
  • Sunday, January 06, 2008 9:33 PMChris Keeble Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     McBain wrote:
    The solution for this exception is very simple. You only have to remove the 'static' modifier at line 54 of DataGridViewNumericUpDownCell.cs

    It worked for me.

     

    The 'static' modifier is there for performance / memory reasons to prevent a separate object being created for every cell in the column.

     

    An alternative solution to McBain's might be to leave the 'static' modifier in, but edit the constructor routine (line 77 in my code) to read:

     

    Code

    if (paintingNumericUpDown == null || paintingNumericUpDown.Disposing || paintingNumericUpDown.IsDisposed)

    Block

     

    I have briefly tested this and it appears to work, avoiding the problems of the ObjectDisposedException being thrown the second time the form / container is created.

     

    Hope it helps others.


    Regards

     

    Chris 

  • Friday, March 28, 2008 3:08 PMManikandan Ramaswami Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    Please help me to customize a datagrid view that is capable of showing HTML/RTF/Any Tabular Format text in one of its column. I need not allow the user to edit the contents, but to display the information in Tabular Format.

    Is it possible to keep Webbrowser control or RichTextBox or even another DataGridView within a DataGridView Column?

    Please help me. Its my urgent need.

    Thanks and Regards,
    ManiX.
  • Saturday, June 07, 2008 6:54 PMlawrence eka Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
     Regis Brid wrote:

    Hi all,

    We just posted two new whitepapers about building custom cells and columns for the DataGridView control:

    Building a custom RadioButton cell and column for the DataGridView control  (Source and Sample Code)

    Building a custom NumericUpDown cell and column for the DataGridView control  (Source and Sample Code )

    The docs, source code and sample code are under http://www.windowsforms.net/WhidbeyFeatures/default.aspx?PageID=2&ItemID=13&Cat=Controls&tabindex=5

    Enjoy!

    -Regis
    Microsoft Windows Forms team
    This post is provided "as-is"



    Is there a way to put an empty string to the numericupdowncolumn? Each time I empty the cell, the value will return to the old value. Is there anybody who could give at least a lead on this?

    many thanks in advance,
    eka.
  • Wednesday, September 17, 2008 8:55 AMVakulsr Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello MaximeR,

    I got the same problem too, so u able to figure out some solution for it or the static thing is the only solution and is it having some dangerous potentials. Looking forward for your reply.

    Regards,
    Vakulsr
  • Monday, November 17, 2008 4:35 PMmpswaim Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    Are these still up? The links don't seem to work any more.

     

  • Thursday, January 15, 2009 6:24 PMSSquared2000 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I am interested in using this control for a commercial product.  The EULA gets installed, but is somewhat confusing.  Is it OK if I use the CS files for a commercial product and have multiple team members compiling?