Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Window Manager Class Question
Message
From
21/03/2009 12:44:51
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01353101
Message ID:
01390271
Views:
39
That's the next thing I was going to suggest. <g> It all depends on what Kevin's attempting to do I think, but since he hasn't replied, we don't know. <g>

~~Bonnie


>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?
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform