I am writing a method that will take a screenshot of a passed form element, and print it out. There are a few challenges I am facing. I want to be able to make this method generic enough to accept just about any type of form element. I set the “element” argument to type “object”. I think I will also need to pass a “type” argument or is there a way to figure out what type the object is after it is passed?
static public void PrintFormElement(object element, ?type?){
}
Am I approaching this problem the right way? Any advice would be appreciated thanks!
I guess that your
elementshould beControl, and everyControlhasDrawToBitmap()method that you can use to take ‘screenshot’ of it.So you can forget all about type parameter, because you won’t need it, because of polymorphism.