Applying the Decorator Pattern to a DataGridView

Article Index:

«»


In my case, I started off with a requirement that some of the DataGridViews in my application must display row numbers in the row header column. To implement that functionality, I turned to Daniel Soper’s excellent article entitled Automatically Adding Numbers to the Rows in a DataGridView. Following Daniel’s example, I was able to create a subclass of DataGridView to add this row numbering behaviour to my DataGridViews.

Unfortunately, as all software developers know, “Change is the only constant” (Heraclitus). Sure enough, my requirements changed and I suddenly needed to add the ability to sort rows in some DataGridViews by using drag and drop techniques. Again, Daniel Soper provided a solution in his article Custom Row and Column Drag and Drop Reordering Operations with the DataGridView. The problem is, some of my DataGridViews needed row numbering, others needed drag and drop sorting, others needed both behaviors and still others needed neither behavior.

To make matters worse, soon after I received yet another DataGridView requirement: the ability to filter the data. The solution for that requirement was provided by Robert Rohde in his article DataGrid with built-in filter functionality. The problem was, how could I combine all of these behaviors without having to create umpteen different subclasses for every combination of those behaviors?

Be Sociable, Share!

    Article Index:

    «»

    Pages: 1 2 3 4

    1 comment to Applying the Decorator Pattern to a DataGridView

    Leave a Reply

     

     

     

    You can use these HTML tags

    <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>