Extended Control viewed as .NET Framework control

G

Guest

Iam extending the .NET Compact Framework textbox control in order to create an advanced textbox control. I have successfully
compiled it and I was able to add it to the ToolBox. Here comes the tricky part: When I create one of this controls in the designer it doesn't look like a Compact Framework textbox, instead it looks like .NET Framework textbox. The weird thing is that it just looks like a .NET Framework control because the object has only the properties, events and methods defined for the Compact Framework textbox control. In short, internally is a Compact Framework control but the designer draws it as a regular .NET Framework Control. When I deploy an aplication containing one of those extended controls on the emulator the program simply exits with code 0, whitout drawing anything.
Any clue of what Iam doing wrong?

Here's my compiling commands:

Designing time

csc /noconfig /nologo /optimize+ /define:DESIGN /target:library
/out:bin\debug\AdvancedTextBoxDesigner.dll
AdvancedTextBox.cs
/r:System.dll
/r:$DesignerPath\System.CF.Windows.Forms.dll
/r:$DesignerPath\System.CF.Design.dll
/r:$DesignerPath\System.CF.Drawing.dll
/r:System.Windows.Forms.dll

Runtime

csc /noconfig /nologo /optimize+ /target:library
/out:bin\debug\AdvancedTextBox.dll
AdvancedTextBox.cs
/r:System.dll
/r:System.Windows.Forms.dll /r:System.Data.dll
/r:System.Drawing.dll /r:System.Web.Services.dll
/r:System.XML.dll

Heres the source code of the control (only extra properties have been added):

using System;
using System.Drawing;
using System.Windows.Forms;

#if DESIGN
[assembly:System.CF.Design.RuntimeAssemblyAttribute(
"AdvancedTextBox,
Version=1.0.0.0,
Culture=neutral,
PublicKeyToken=null")]
#endif
namespace DragoSolutions.Win.Extensions
{
public class AdvancedTextBox : TextBox
{
private string m_strOriginalText;
private string m_strTextDataMember;
public AdvancedTextBox() {}

public string originalText
{
get { return m_strOriginalText; }
//set { m_strOriginalText = value; }
}

public string textDataMember
{
get { return m_strTextDataMember; }
set { m_strTextDataMember = value; }
}
}
}

Thank you for your time.

Victor Luaces.
 
A

Alex Yakhnin [MVP]

You will have to provide your own design-time painting. Take a look at
OpenNETCF's TextBoxEx:

http://www.opennetcf.org/SourceBrow...oot/Source/OpenNETCF.Windows.Forms/TextBox.cs

--
Alex Yakhnin .NET CF MVP
www.intelliprog.com | www.opennetcf.org

vluacesb said:
Iam extending the .NET Compact Framework textbox control in order to
create an advanced textbox control. I have successfully
compiled it and I was able to add it to the ToolBox. Here comes the tricky
part: When I create one of this controls in the designer it doesn't look
like a Compact Framework textbox, instead it looks like .NET Framework
textbox. The weird thing is that it just looks like a .NET Framework control
because the object has only the properties, events and methods defined for
the Compact Framework textbox control. In short, internally is a Compact
Framework control but the designer draws it as a regular .NET Framework
Control. When I deploy an aplication containing one of those extended
controls on the emulator the program simply exits with code 0, whitout
drawing anything.
Any clue of what Iam doing wrong?

Here's my compiling commands:

Designing time

csc /noconfig /nologo /optimize+ /define:DESIGN /target:library
/out:bin\debug\AdvancedTextBoxDesigner.dll
AdvancedTextBox.cs
/r:System.dll
/r:$DesignerPath\System.CF.Windows.Forms.dll
/r:$DesignerPath\System.CF.Design.dll
/r:$DesignerPath\System.CF.Drawing.dll
/r:System.Windows.Forms.dll

Runtime

csc /noconfig /nologo /optimize+ /target:library
/out:bin\debug\AdvancedTextBox.dll
AdvancedTextBox.cs
/r:System.dll
/r:System.Windows.Forms.dll /r:System.Data.dll
/r:System.Drawing.dll /r:System.Web.Services.dll
/r:System.XML.dll

Heres the source code of the control (only extra properties have been added):

using System;
using System.Drawing;
using System.Windows.Forms;

#if DESIGN
[assembly:System.CF.Design.RuntimeAssemblyAttribute(
"AdvancedTextBox,
Version=1.0.0.0,
Culture=neutral,
PublicKeyToken=null")]
#endif
namespace DragoSolutions.Win.Extensions
{
public class AdvancedTextBox : TextBox
{
private string m_strOriginalText;
private string m_strTextDataMember;
public AdvancedTextBox() {}

public string originalText
{
get { return m_strOriginalText; }
//set { m_strOriginalText = value; }
}

public string textDataMember
{
get { return m_strTextDataMember; }
set { m_strTextDataMember = value; }
}
}
}

Thank you for your time.

Victor Luaces.
 
V

victor Luaces

I've just added my own desing time painting, which only delegates on the
base class. My source code looks like this:

using System;
using System.Drawing;
using System.Windows.Forms;

#if DESIGN
[assembly: System.CF.Design.RuntimeAssemblyAttribute
("DragoSolutions.Windows.Forms.AdvancedTextBox,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null")]
#endif
namespace DragoSolutions.Windows.Forms
{
/// <summary>
/// Descripción breve de Class1.
/// </summary>
public class AdvancedTextBox : TextBox
{
#if DESIGN

// Design Time Painting

protected override void OnPaintBackground
(System.Windows.Forms.PaintEventArgs pea)
{
base.OnPaintBackground(pea);
}

protected override void OnPaint
(System.Windows.Forms.PaintEventArgs pea)
{
base.OnPaint(pea);
}

protected override void OnResize(System.EventArgs ea)
{
this.Invalidate();
base.OnResize(ea);
}
#endif

#if !DESIGN

private string m_lastRefreshedValue;
private string m_strTextDataMember;
private string m_type;

public AdvancedTextBox()
{
}

//Advanced Properties

public string lastRefreshedValue
{
get { return m_lastRefreshedValue; }
set { m_lastRefreshedValue = value; }
}

public string textDataMember
{
get { return m_strTextDataMember; }
set { m_strTextDataMember = value; }
}

public string type
{
get { return m_type;}
set {m_type = value;}
}
#endif
}
}

The problem still remains the same. During compilation I recieve
serveral warnings indicating that the class
Textbox and methods like OnPaint are defined on serveral places but the
Compact Framework definition is used. So I
don't know why do I get a regular .NET control during
designing time.

Once I run the aplication no errors are thrown, it just
exits with code 0. I get some suspicious messages on the
debug window like:

loading 'mscorlib.dll', can't load symbols
loading SmartDeviceApplication.exe, symbols loaded
loading DragoSolutions.Windows.Forms.AdvancedTextBox.dll,
can´t load symbols
loading System.Drawing.dll, can't load symbols
loading System.dll, can't load symbols
loading System.Windows.Forms.dll, can't load symbols

I am not familiar at all with the loading process of the
Compact Framework so I don't know if those messages are
an issue.

Anyway, thank very much for your previous tip.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top