Menu

DataGrid - Change cell attributes after load

Help
2006-12-02
2013-04-23
  • Nobody/Anonymous

    Hi Davide,

    Thanks for this great tool - it has helped me a great deal so far :)

    The problem I have at the moment is that I am not sure how to change the backcolor of a specific cell or cells.  I am working on a production interface to capture the number of units produced in a week.  The DataGrid shows weeks 1 to 53 of the year (week 53 only valid in certain years, according to ISO 8601 standard).

    Once the user enters the year to be captured in the first cell of that row, I want to change the backcolor of the week cells that do not form part of the specific fiscal year, and possibly change the editable status as well (e.g. Fiscal 2007 runs from week 13 in 2006 to week 12 in 2007, so I want to change the backcolor of weeks 1 to 12 in 2006 as well as week 53 to red, so that the user knows not to enter any data in those cells).

    Is there a way that I can do this, or perhaps a different way of approaching this problem with one of your other grids?  I chose the DataGrid because I would be reading and writing data to a MySQL database.

    Thanks again,

    Gareth

     
    • Davide Icardi

      Davide Icardi - 2006-12-02

      If you use DataGrid you must simply change the required cells/columns and then force a redraw of the grid using grid.Invalidate method.
      Each time that the grid draw itself it reads the properties of the cells.

      Davide

       
      • Nobody/Anonymous

        Err....sorry for wasting your time Davide - after many hours of struggling, it turned out to be 3 simple lines of code to change the backcolor.  I just don't understand how I missed the getCell function all along :p

        Thanks again,

        Gareth

         
    • Nobody/Anonymous

      Thanks for the reply Davide.  However, I am unsure as to how to change the cell or column properties once they have already been created.  I have tried something similar to when the grid is initially drawn (setting of the datacell view, etc.), but have come up short every time.

      Any help in the right direction will be greatly appreciated.

      Thanks,
      Gareth

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.