Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Window Manager Class Question
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01353101
Message ID:
01389902
Vues:
37
PJMI,
return (Form) oRetVal;
>I'm revisting this topic....
>
>I have created the interface and the form's are implementing it. In my Forms Manager class I have:
>
>public static Form GetOpenForm(FormType Type, int iRecordKey)
>{
>    Form oRetVal = null;
>
>    foreach (IFormForManager oForm in _Forms)
>    {
>        if (oForm.FormType == Type && oForm.iRecordKey == iRecordKey)
>        {
>            oRetVal = oForm;
>            break;
>        }
>    }
>
>    return oRetVal;
>}
>
>
>When I comple I get "Cannot implicitly convert type 'IFormForManager' to 'System.Windows.Forms.Form'.".
>
>The return value is type Form, but the foreach creates instances of IFormForManager. I'm not completely sure how to make this work.
>
>
>
>
>
>
>
>>Read my lips ... Interfaces!! =0)
>>
>>
>>public interface IFormForManager
>>{
>>    int iRecordKey {get;set;}
>>}
>>
>>
>>Each of your Forms that need to be controlled by your FormsManager will have to be changed to implement the IFormForManager interface.
>>
>>Then, your class would would look like this:
>>
>>
>>public Form GetOpenForm(FormTypes type, int iRecordKey)
>>{
>>	Form oRetVal = null;
>>
>>	foreach(IFormForManager oForm in oWindows)
>>	{
>>		if (oForm.iRecordKey == iRecordKey)
>>		{
>>		    oRetVal = oForm;
>>		}
>>	}
>>	return oRetVal;
>>}
>>
>>
>>~~Bonnie
>>
>>
>>
>>
>>
>>
>>
>>>I have a window manager class. It maintains references to open User and Item forms:
>>>
>>>At the top I create an array list:
>>>
>>>
>>>private static ArrayList oWindows = new ArrayList();
>>>
>>>
>>>The I have a method to return an instance of a form in the collection:
>>>
>>>
>>>public void GetOpenForm(FormTypes type, int iRecordKey)
>>>{
>>>	form oRetVal = null;
>>>
>>>	foreach(form oForm in oWindows)
>>>	{
>>>		if (oForm.iRecordKey == iRecordKey)
>>>		{
>>>		}
>>>	}
>>>}
>>>
>>>
>>>Problem is, the references to oForm in the code above are not User or Item forms, so the iRecordkey reference fails to compile. Add to this, the Item and User forms are not based off any single base form.
>>>
>>>How do I make oForm "know" about iRecordKey?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform