Fetstil Fetstil Kursiv Understrykning linje färgläggning tabellverk Punktlista Nummerlista Vänster Centrerat högerställt Utfyllt Länk Bild htmlmode
  • Forum & Blog
    • Forum - översikt
      • .Net
        • asp.net generellt
        • c#
        • vb.net
        • f#
        • silverlight
        • microsoft surface
        • visual studio .net
      • databaser
        • sql-server
        • databaser
        • access
        • mysql
      • mjukvara klient
        • datorer och komponenter
        • nätverk, lan/wan
        • operativsystem
        • programvaror
        • säkerhet, inställningar
        • windows server
        • allmänt
        • crystal reports
        • exchange/outlook
        • microsoft office
      • mjukvara server
        • active directory
        • biztalk
        • exchange
        • linux
        • sharepoint
        • webbservers
        • sql server
      • appar (win/mobil)
      • programspråk
        • c++
        • delphi
        • java
        • quick basic
        • visual basic
      • scripting
        • asp 3.0
        • flash actionscript
        • html css
        • javascript
        • php
        • regular expresssion
        • xml
      • spel och grafik
        • DirectX
        • Spel och grafik
      • ledning
        • Arkitektur
        • Systemutveckling
        • krav och test
        • projektledning
        • ledningsfrågor
      • vb-sektioner
        • activeX
        • windows api
        • elektronik
        • internet
        • komponenter
        • nätverk
        • operativsystem
      • övriga forum
        • arbete karriär
        • erbjuda uppdrag och tjänster
        • juridiska frågor
        • köp och sälj
        • matematik och fysik
        • intern information
        • skrivklåda
        • webb-operatörer
    • Posta inlägg i forumet
    • Chatta med andra
  • Konto
    • Medlemssida
    • Byta lösenord
    • Bli bonsumedlem
    • iMail
  • Material
    • Tips & tricks
    • Artiklar
    • Programarkiv
  • JOBB
  • Student
    • Studentlicenser
  • KONTAKT
    • Om pellesoft
    • Grundare
    • Kontakta oss
    • Annonsering
    • Partners
    • Felanmälan
  • Logga in

Hem / Forum översikt / inlägg

Posta nytt inlägg


window forms control is automatically deleted

Postades av 2006-03-15 13:13:52 - Tony Johansson, i forum c# (c-sharp), Tråden har 2 Kommentarer och lästs av 514 personer

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


Svara

Sv: window forms control is automatically deleted

Postades av 2006-03-15 15:19:39 - Emma Magnusson

This only occurs when you have the window open if I remember correctly. If the form where your controls are placed are closed and you make sure only to build the control/solution where the control is placed it should be ok. (Might be I was lucky since I worked with it in two different projects - but they are part of the same solution.)

I remember being able to rescue the data sometimes, by closing the project, not saving anything, which means I saved before my builds, if the went south, my forms where still intact on restart.

I gather it's the same kind of solution for inherited controls as for completely self designed, so good luck.

/Emma


Svara

Sv:window forms control is automatically deleted

Postades av 2006-03-15 15:45:04 - Tony Johansson

Hello!

I don't think you understand me correctly.
I try below to add some more information to my problem.

Most of the times there is a project containing several forms and some code class files.
One file in the project is a code class file which contains this ExtTextBox
public class ExtTextBox : System.Windows.Forms.TextBox
{
public ExtTextBox() {}
}

When you build the project(assemby) and you get some compile error and you then use the View Designer on a form containging this control the control will be deleted.


//Tony


Svara

Nyligen

  • 09:09 Vill du köpa medicinska tester?
  • 12:47 Vem beviljar assistansen – kommune
  • 14:17 Någon med erfarenhet av hemstädnin
  • 14:14 Bör man använda sig av en båtförme
  • 14:12 Finns det någon intressant hundblo
  • 14:25 Tips på verktyg för att skapa QR-k
  • 14:23 Tips på verktyg för att skapa QR-k
  • 20:52 Fungerer innskuddsbonuser egentlig

Sidor

  • Hem
  • Bli bonusmedlem
  • Läs artiklar
  • Chatta med andra
  • Sök och erbjud jobb
  • Kontakta oss
  • Studentlicenser
  • Skriv en artikel

Statistik

Antal besökare:
Antal medlemmar:
Antal inlägg:
Online:
På chatten:
4 569 169
27 953
271 705
1 345
0

Kontakta oss

Frågor runt konsultation, rådgivning, uppdrag, rekrytering, annonsering och övriga ärenden. Ring: 0730-88 22 24 | pelle@pellesoft.se

© 1986-2013 PelleSoft AB. Last Build 4.1.7169.18070 (2019-08-18 10:02:21) 4.0.30319.42000
  • Om
  • Kontakta
  • Regler
  • Cookies