Showing posts with label Today's Help. Show all posts
Showing posts with label Today's Help. Show all posts

Thursday, March 14, 2013

How to design Windows Forms with Abstract Inheritance?

It happened few days ago when I got to this nice error:

The designer must create an instance of type '... .BaseClass.TabBaseControl' but it cannot because the type is declared as abstract.


The scenario was like this: I had a Base class where a defined abstract members that where implemented in a form. When wanted to see the design of the page this warning appeared even though the application runs just fine. So how to get rid of this error:  "The designer must create an instance of type 'SchedeMaterialiDaTaglio.BaseClass.TabBaseControl' but it cannot because the type is declared as abstract. " ?
Well, searching around I got to this post http://www.platinumbay.com/blogs/dotneticated/archive/2008/01/05/designing-windows-forms-with-abstract-inheritance.aspx where I found part of the solution. 
Here it is:

 public class AbstractCommunicatorProvider : TypeDescriptionProvider
    {
        public AbstractCommunicatorProvider()
            : base(TypeDescriptor.GetProvider(typeof(UserControl)))
        {
        }
        public override Type GetReflectionType(Type objectType, object instance)
        {
            return typeof(UserControl);
        }
        public override object CreateInstance(IServiceProvider provider, Type objectType, Type[] argTypes, object[] args)
        {
            objectType = typeof(UserControl);
            return base.CreateInstance(provider, objectType, argTypes, args);
        }
    }
You define this class in inherited class(it only worked for me in this way) and you must also put this for base class and inherited class:

    [TypeDescriptionProvider(typeof(AbstractCommunicatorProvider))]
    public partial class TabUC : TabBaseControl{}

    [TypeDescriptionProvider(typeof(AbstractCommunicatorProvider))]
    public abstract class TabBaseControl : UserControl, ITabBase{}
Of course that you will have to include System.ComponentModel namespace and others just as needed.
Hope it helped. Ciao.

Friday, May 11, 2012

How to make an update query using join in SQL

Today it helped me a lot this page which instructed me how to make an update query using join. So you can go and check it out on http://www.bennadel.com/blog/938-Using-A-SQL-JOIN-In-A-SQL-UPDATE-Statement-Thanks-John-Eric-.htm

Here you can see how I wrote my update command:


                        UPDATE  O
set O.Payed = Payed - 1, O.PaymentDate = null , refPaymentMethodId = null
from [Orders] O
join PaymentMethod pm on pm.PaymentMethodID = O.refPaymentMethodID
where OrderID = @OrderID and pm.GenerateReceipt = 1;
Cheers.

Friday, March 9, 2012

How To Allow Blocked Content on Internet Explorer

I thought that will be great if I will post here on this blog for anytime when I found an article on the internet that helped me. So based on this idea I am going to give you a short description of problem(found in title, maybe) and the link to the solution.
So one of my question of today was: How To Allow Blocked Content on Internet Explorer?
Instructions found you can get at  http://www.genopro.com/help/report-generator/allow-blocked-content/
Regards