473,473 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

context.Instance().ParentForm has wrong type

2 New Member
Hi all! I have a form with controls and non-visual components. Some of them implements interface MyInterface and some have a MyInterface Property.
Task is : select MyIntrerface Property for control in property grid from all components that implement MyInterface.

Descibe code:

Expand|Select|Wrap|Line Numbers
  1. interface MyInterface {}
  2.  
  3. public class ControlClass : UserControl
  4. {
  5.   MyInterface MyInterfaceProvider {get; set;}
  6. }
  7.  
  8. public class ComponentClass : Component, MyInterface{}
  9.  
  10. public  class MainForm:Form
  11. {
  12.  ControlClass _myControl;
  13.  ComponentClass _myComponent;
  14.  [...]
  15. }
  16.  
I wrote a typeconverter to perform string <=> MyInterface types conversation:

Expand|Select|Wrap|Line Numbers
  1. public class InterfaceTypeConverter: TypeConverter{
  2.  
  3.   public override  
  4.       StandardValuesCollection GetStandardValues(
  5.                                                        ITypeDescriptorContext context){
  6.    [...checks]
  7.   // try to obtain ParentForm for getting _myComponent;
  8.   ComponentParentForm = (context.Instance() as _myControl).ParentForm;
  9.  
  10.   MainForm MF = ComponentParentForm as MainForm;
  11.   [...]
  12. }
  13.  [...]
  14. }
  15.  
I have:

MF == null

but

_myComponent.ParentForm is MainForm

but

ComponentParentForm is Form

!! ComponentParentForm is not MainForm !!

ComponentParentForm.Name == "MainForm"

How i can get ComponentParentForm with MainForm type ?
Oct 13 '09 #1
1 1851
Linkelf
2 New Member
Problem Solved !
I cant and dont need convert ParentForm into MainForm type. All components i needed place in ComponentParentForm.Container.Components
Oct 13 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: SPG | last post by:
Hi, I am relatively new to TOMCAT, and am trying to deploy a web app using it. I have a domain name that I want to use to access my web app directly. By default, I deploy my WAR, and it deploys...
2
by: Hareth | last post by:
I created a context menu, linked to notifyicon. (a system tray menu). The menu pops up when u right click on it, in the system tray. (it works fine) When I delete some of the menuitems & rebuild...
4
by: Jason Huang | last post by:
Hi, In my ASP.Net C# Windows Form project, I have 2 forms, FormParent and FormChild. I have a Button1_Click event in FormParent, and the codes are: private void Button1_Click(object sender,...
2
by: dave | last post by:
This little problem is driving me nuts!! On my webform page I create 2 variables.. Protected p_dml As String = "I" Public Const mwv_id As Integer = 0 ' originally had mwv_id as Protected
13
by: Metallicraft | last post by:
I have a vb6 application. On the main form is a picture box with one or two images and several pieces of text displayed in it. These are created on the fly using gdi32 routines that are all in a...
5
by: Adda | last post by:
Is it possible to set a variable to a current instance of a running object without using the New keyword? Here is my situation. I have been trying to add a record to a dataset on a Parent Mdi...
12
by: Tom W | last post by:
What's the difference in these three?
10
by: John M. Gabriele | last post by:
The following short program fails: ----------------------- code ------------------------ #!/usr/bin/python class Parent( object ): def __init__( self ): self.x = 9 print "Inside...
4
by: Harry Haller | last post by:
What's wrong with this: Error 3 'System.Web.Caching.Cache' is a 'type', which is not valid in the given context public List<AssetSummaryGetAssetSummary() { return...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.