all groups > dotnet windows forms designtime > february 2005 >
You're in the

dotnet windows forms designtime

group:

Disappearing Controls when the designer loads a form.


Disappearing Controls when the designer loads a form. Michael AbiEzzi
2/18/2005 3:31:03 PM
dotnet windows forms designtime: I am using Visual Studio 2003 (C#) with the .NET Framework 1.1 SP1.

I suspect that I have encountered a bug in Visual Studio. I have three
user controls (EditorGrid, EditableGrid, and ReadOnlyGrid) which inherit from
Abstract Grid. AbstractGrid Inherits from TitledFrame and TitledFrame
inherits from ContainerControl. Anyways, the three user controls that inherit
from AbstractGrid can be dropped onto a form with a designer, and everything
will work fine. But if you try to drop it on a TabPage, we get trouble. At
first if you just drop it on the TabPage, save, and close the designer
window, then compile, there are no problems. But if you drop it on the
TabPage and compile while the designer is still open the control disappears
and the two following errors occur:

The variable 'editorGrid1' is either undeclared or was never assigned.
There is already a component named 'editorGrid1'. Components must have
unique names, and names must be case-insensitive. A name also cannot
conflict with the name of any component in an inherited class.

So basically, the anomaly occurs when the design reloads (Either when
opening a form in a designer, or when recompiling while the designer is still
open.)

The workaround is to selected the control from the Properties Window's
Object list (the dropdown list with all the controls and components in it),
then click on the designers document tab do shift focus to the designer. Then
press Ctrl+X to cut the control, then focus to the TabPage that you want the
control to be on, and then press Ctrl+V to paste it where it belongs. At this
time you can save your changes, and close the designer before recompiling,
and then you will be fine. The form will run just fine, without any problems.
It just becomes annoying when you want to use the designer to have to keep
cutting and pasting the controls back where the belong. Especially if one
form has seven to ten controls on it.

Since all three controls that inherit from AbstractGrid have this problem,
it is probably safe to deduce that something in that class is triggering the
anomaly. It was working at one point, but as I added more code to it, the
anomaly started occurring. I wasn’t able to find out what part of the code is
causing this to happen. I'll paste the AbstractGrid code and the code from
the class that it derives from below.

One thing I did do, was convert the project to run in visual studio .net
2005 beta, and the anomaly went away. That makes me suspect that is a VS 2003
issue, and not my code (my code just seems to trigger the bug some how).
Unfortunately, this project can’t built on a beta SDK, and we cant wait for
2005 to be released, so I’m hoping that there’s a solution for VS 2003.

So just to be clear, TitledFrame, the class the AbstractGrid inherits from,
does not have any problems. And AbstractGrid didn’t have any problems until I
made simply changes such as maybe changing implementations of methods or
adding properties, events, and event handling. Lastly, I wasn’t able to pin
point the code causing the problem no matter how hard I tried, that’s why I
am posting this message.

Thank you for taking the time to read this.

//-------------------------------------------------------------------------------

using System;
using System.Data;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using PointeBlank.Foundation.Controls;
using PointeBlank.Foundation.Data;
using PointeBlank.Foundation.UIManagement;
using Infragistics.Win.UltraWinGrid;
using Infragistics.Win;

namespace PointeBlank.HomePointe.UserControls
{

public abstract class AbstractGrid : TitledFrame
{

#region Feilds

protected Infragistics.Win.UltraWinGrid.UltraGrid grid = null;
private string visibleColumns = "*";
private string readOnlyColumns = "";
private ArrayList readOnlyColumnsList;
private string columnAliases = "";
private bool autoFitColumns = false;
private bool columnHeadersVisible = true;
protected string recordTypeName = "record";
private Hashtable storedProcedures = new Hashtable();
private Hashtable inputValues = new Hashtable();
private Hashtable listKeys = new Hashtable();
private Hashtable codeTypes = new Hashtable();
private ListLoader listLoader;
private bool areGridEventsSetup = false;
protected DataTable dataTable;
private UIMessageHandler messageHandler;
private ControlGuiDecorator controlGuiDecorator;
private object director;

#endregion

#region Properties

public UIMessageHandler MessageHandler
{
get{ return messageHandler; }
set{ messageHandler = value; }
}

public ControlGuiDecorator ControlGuiDecorator
{
get{ return controlGuiDecorator; }
set{ controlGuiDecorator = value; }
}

public ListLoader ListLoaderForComboColumns
{
get{ return listLoader; }
set{ listLoader = value; }
}

[DefaultValue("*")]
[Category("Appearance"), Description("Gets/sets the columns that are
visible or not " +
"(Type in the column names seperated by commas).")]
public string VisibleColumns
{
get{ return visibleColumns; }
set{ visibleColumns = value; }
}

[DefaultValue("")]
[Category("Appearance"), Description("Gets/sets the columns that are
read-only or not " +
"(Type in the column names seperated by commas).")]
public string ReadOnlyColumns
{
get{ return readOnlyColumns; }
set{ readOnlyColumns = value; }
}

[DefaultValue("*")]
[Category("Appearance"), Description("Gets/sets column aliases (i.e.
nme=Name, phn=Phone).")]
public string ColumnAliases
{
get{ return columnAliases; }
set{ columnAliases = value; }
}

[DefaultValue(false)]
[Category("Appearance"), Description("Gets/sets if the columns are
autofit or not.")]
public bool AutoFitColumns
{
get{ return autoFitColumns; }
set{ autoFitColumns = value; }
}

[DefaultValue(true)]
[Category("Appearance"), Description("Gets/sets if column header portion
is visible or not.")]
public bool ColumnHeadersVisible
{
get{ return columnHeadersVisible; }
set{ columnHeadersVisible = value; }
}

/// <summary>
/// Specifies the name that you call an individual record.
/// This name will be used in messages boxes. (i.e. "The Phone
/// Number was not saved." (Where 'Phone Number' is the RecordTypeName.) )
/// </summary>
[DefaultValue("record")]
[Category("Appearance")]
[Description("Specifies the name that you call an individual record."+
" This name will be used in messages boxes. (i.e. \"The Phone "+
Re: Disappearing Controls when the designer loads a form. Alex Clark
3/8/2005 5:28:48 PM
Hi Michael,

It's a known bug in VS.NET and Microsoft have got a hotfix for it, but you
need to contact PSS in order to get it as it's not "release" ready. I
believe it is under KB842706. I've installed it myself and although it's
not 100% perfect, it's certainly a major improvement (after screaming at the
screen and having to add 44 user controls back onto my main form from
scratch for about the 8th time, anything was an improvement!).

Cheers,
Alex



"Michael AbiEzzi" <Michael AbiEzzi@discussions.microsoft.com> wrote in
message news:CD1EFB43-C5B7-464C-B8DB-57F26952F2F7@microsoft.com...
[quoted text, click to view]
Re: Disappearing Controls when the designer loads a form. Uri Dor
4/6/2005 1:47:41 PM
I had similar problems, which were traced to an exception my user
control threw while in the designer.
The easy way to debug this is to run one instance of VS.NET, open your
solution, change the project debugging properties from "project" to
"program" and specifying devenv.exe with the SLN file as a parameter.
then you start debugging, which loads another VS.NET. in that (the
debugged) VS.NET you do whatever reproduces your designer problem, and
the 1st VS.NET catches the exception (don't forget to turn on "break
into debugger when exception is thrown" in "exceptions")

worked for me

[quoted text, click to view]
Re: Disappearing Controls when the designer loads a form. joeycalisay
4/7/2005 12:00:00 AM
worked with everyone who knows how to debug... :p

--
Joey Calisay
http://spaces.msn.com/members/joeycalisay/


[quoted text, click to view]
//--------------------------------------------------------------------------
-----
[quoted text, click to view]
AddThis Social Bookmark Button