473,386 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

C# Win App class problem

pod
298 100+
I am trying to split my code over several class files but I am having problems accessing them.

I guess I have a hard time with inheritance.

Here's is my setup:

I have a file called OVRform which contains all the code behind for the form.
Expand|Select|Wrap|Line Numbers
  1. namespace Tracking_WIN
  2. {
  3.     public partial class OVRform : Form
  4. ...
  5.  

I have another file, a class file called audit.cs and here is all of the code
Expand|Select|Wrap|Line Numbers
  1.  
  2. namespace Tracking_WIN
  3. {
  4.     public partial class audit : OVRform
  5.     {
  6.         public string dojo
  7.         {
  8.             get { return doubleJeopardy(); }
  9.         }
  10.  
  11.         public string doubleJeopardy()
  12.         {
  13.  
  14.             try
  15.             {
  16.                 return "yes";
  17.             }
  18.             catch
  19.             {
  20.                 return "no";
  21.             }
  22.         }
  23.     }
  24. }
  25.  

How can I get access to the dojo property of the audit object from the OVRform ?

Am I being clear enough?


Thanks for any response


Perry
Sep 24 '07 #1
2 1119
Plater
7,872 Expert 4TB
Short Answer: You can't.
You would need an instance of audit to manipulate members created in the audit class.

For an easy demonstration.
Create an instance of Control and of say ListBox.
ListBox derives from control (inherits)
But Control cannot use a .SelectedItem property because it's not a ListBox.
Sep 24 '07 #2
pod
298 100+
OK, I created an instance of audit and can get to the dojo property.

Expand|Select|Wrap|Line Numbers
  1.             audit auditObj = new audit();
  2.  
But something strange happens...

If this instance is set in the main loading function I get an infinite loop, creating the audit instance reloads the form which recreates the audit instance ....



Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Configuration;
  5. using System.Data;
  6. using System.Data.OleDb;
  7. using System.Drawing;
  8. using System.Security.Principal;
  9. using System.Text;
  10. using System.Windows.Forms;
  11.  
  12. using winDBtools;
  13. using customFunctions;
  14.  
  15. namespace Tracking_WIN
  16. {
  17.     public partial class OVRform : Form
  18.     {
  19.  
  20.         public OVRform()           //generated function
  21.         {
  22.             InitializeComponent(); //generated function
  23.             InitEnv();
  24.         }
  25.  
I have a lot of learning to do, I ordered a book, I hope it has a clear picture of the Object Oriented Programming :)
Sep 24 '07 #3

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

Similar topics

1
by: Steve | last post by:
Hello, I'm encountering an unexpected behavior when using the "new" modifier in a derived class to hide an inherited base class property. I use "new" intentionally so I can change the Type of...
9
by: Banaticus Bart | last post by:
I wrote an abstract base class from which I've derived a few other classes. I'd like to create a base class array where each element is an instance of a derived object. I can create a base class...
21
by: Jon Slaughter | last post by:
I have a class that is basicaly duplicated throughout several files with only members names changing according to the class name yet with virtually the exact same coding going on. e.g. class...
21
by: Mark Broadbent | last post by:
Consider the following statements //------- Item i = Basket.Items; //indexer is used to return instance of class Item Basket.Items.Remove(); //method on class item is fired item i = new...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
8
by: tshad | last post by:
I cannot seem to get the asp:textbox to use classes. Style works fine. I am trying to set the textbox to act like a label in some instance so it doesn't have a border, readonly and the background...
4
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
5
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
3
by: Hamilton Woods | last post by:
Diehards, I developed a template matrix class back around 1992 using Borland C++ 4.5 (ancestor of C++ Builder) and haven't touched it until a few days ago. I pulled it from the freezer and...
3
by: TamusJRoyce | last post by:
Hello. This is my first thread here. My problem has probably been came across by a lot of people, but tutorials and things I've seen don't address it (usually too basic). My problem is that I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.