473,395 Members | 1,412 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,395 software developers and data experts.

window forms control is automatically deleted

fds
Hello!

I have a very specific question and that is about how to inherit a control
for example the control System.Windows.Forms.TextBox without causing the
environment to delete the control when there are some compile errors. It's
the same problem with any visual control that you inherit. The control is
deleted as soon as you use the View Designer when there is compile error.
It's very easy to reproduce my problem. You can do it in this way.
1. Create a class called ExtTextBox like this. In my example here I have
removed the namespace. But if you include namespace make sure you have
access to it.
public class ExtTextBox : System.Windows.Forms.TextBox
{
public ExtTextBox() {}
}
As you can see this class ExtTextBox inherit from the ordinary components
System.Windows.Forms.TextBox in the .NET framework

2. Create a windows form with any name. The default is Form1

3. Use the View Designer and create the control TextBox in the window form.
My control was called textBox1

4. Because I want the control textBox1 to be an instance of ExtTextBox I
have to edit the InitializeComponent() I don't have any other idea.
Here is an extract from my windows form called Form1.
Only the interesting rows is written. Two rows is important here.
First saying that control textBox1 is of type ExtTextBox.
Second edit the InitializeComponent and say that textBox1 is an instance of
ExtTextBox.
public class Form1 : Form
{
private ExtTextBox textBox1; // First saying that control textBox1 is of
type ExtTextBox.

....
....
....

Private void InitializeComponent()
{
//Second edit the InitializeComponent and say that textBox1 is an instance
of ExtTextBox
this.textBox1= new ExtTextBox();
...
...
...
}
}

5 Compile. Hopefully you don't get any compile errors. When you run the
applikation only the testBox is being displayed. The problem might start
even here. If you get any compile error and you use the View Designer the
control named textBox1 is being deleted automatically.

6 If you don't get any compile error make a change so you get a compile
error and then use the View Designer the control named textBox1 is being
deleted automatically.

7 Now to my question. I can't use controls that being deleted automatically
when I get compile error.

8. If I want to use inheritance on visual control how do I do. I just can't
have it as it is now.

9 I just can't use inheritance in the way I do now.

10. I hope that you have a good suggestion how I should use inheritance on
visual control to avoid this kind of problems.

//Tony

Mar 15 '06 #1
0 1428

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Matt Warner | last post by:
Hi guys, A couple of people have already posted questions about similar issues but haven't had any response. Occasionally, sometimes after running the app for a few hours, it bombs out saying...
6
by: DraguVaso | last post by:
Hi, In my application, on some given actions while debugging in Visual Studio, I suddenly get a "System.ComponentModel.Win32Exception was unhandled" Message="Error creating window handle."...
4
by: Charles Law | last post by:
I have an MDI application which contains a menu, MDI child form and properties window. On my Edit menu I have Cut, Copy, Paste, and Delete. The shortcut key for Delete is set to Del. In the...
3
by: DotNetNewbie | last post by:
I am reading the book Teach Yourself Microsoft Visual Basic .Net 2003 in 21 Days. I am having trouble getting one of the exercises to work at the end of day 4. Exercises: 1. Create a new...
1
by: Flack | last post by:
Hey guys, Here is whats happening. I have a StringBuilder, a TextBox, and a TabControl with one TabPage. On my main form, I created and displayed a fairly big maze. While the app is solving...
0
by: tony | last post by:
Hello! I have a very specific question and that is about how to inherit a control for example the control System.Windows.Forms.TextBox without causing the environment to delete the control when...
0
by: Tony Johansson | last post by:
Hello! I have a very specific question and that is about how to inherit a visual control for example the control System.Windows.Forms.TextBox without causing the environment to delete the...
10
by: David Lee Conley | last post by:
When I open the Data Sources window and create a new data source, everything works fine. But if I have a form showing in the IDE, the Data Sources window becomes disabled and doesn't display any...
7
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm new to Visual Studio 2005. I'm creating a windows application using Visual Basic. After I added a control to a form and added some codings to the control, I want to rename the control. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
0
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...

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.