Author Topic: Derived class  (Read 2310 times)

0 Members and 1 Guest are viewing this topic.

mohnston

  • Bull Frog
  • Posts: 305
  • CAD Programmer
Derived class
« on: April 19, 2007, 02:59:52 PM »
From an example of deriving classes (thanks again Tony T.) I got an idea for something that I'm working on.
I had a VB version of a "CAD Grid". It simply created a table on an autocad drawing.
I know that we now have actual AutoCAD Tables but I don't like them. (try editing one of any size)

So I want to make a C#.NET version of CADGrid.
The CAD grid I want to create has rows, columns, values, headers, fonts etc. just like the datagridview control.
So I create my CADGrid class like so:
Code: [Select]
public class CADGrid: System.Windows.Forms.DataGridView
I don't intend to use the DataGridView control at all. But it has a structure and properties that are very similar to the grid I want to make.

This is the first time that I have done such a thing so I welcome your comments.
Pitfalls, concerns, recommendations, mocking, ridicule - whatever.
It's amazing what you can do when you don't know what you can't do.
CAD Programming Solutions

MickD

  • King Gator
  • Posts: 3651
  • (x-in)->[process]->(y-out) ... simples!
Re: Derived class
« Reply #1 on: April 19, 2007, 06:55:45 PM »
While it sounds good in theory and is a good example of using inheritance, the problem comes when placing your text, the data grid does all the menial x/y location calculations for you to paint the text in a particular cell, all you give it is a cell coordinate ref and the text, it looks after the rest.
If you want to use the data from the grid that's ok but unless you can get the grid geometry you will still have to calculate your insert points your self.
You could create your own data grid though, start with a cell object, get it to draw and place text inside as required, create a new class that uses this cell object to create a row object, then a grid object and so on.
Sounds like fun!
« Last Edit: April 19, 2007, 06:57:09 PM by MickD »
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien