property throws Exception in visual designer! 
Author Message
 property throws Exception in visual designer!

hi i have a problem concerning custom properties. i have following property
and the problem is when i open the designer an exception occures because the
values aren't known at designtime. how can i avoid this?

is there a way to hide the property from the designer? or should i make it
to a method?

public string SelectedValueDBKey
{
get
{
if (Text=="")
return "null";
return dbConn.gettext("select "+idCol+" from "+table+" where
"+textCol+"='"+Text+"'");

Quote:
}

set
{
if (value==null)
Text="";
else
Text = dbConn.gettext("select "+textCol+" from "+table+" where
"+idCol+"='"+value+"'");
Quote:
}
}



Sat, 25 Jun 2005 17:31:27 GMT  
 property throws Exception in visual designer!
Cody,

    Place the Browsable attribute on your property, passing in false to the
constructor, like so:

[Browsable(false)]
public string SelectedValueDBKey
{
get
{
if (Text=="")
return "null";
return dbConn.gettext("select "+idCol+" from "+table+" where
"+textCol+"='"+Text+"'");

Quote:
}

set
{
if (value==null)
Text="";
else
Text = dbConn.gettext("select "+textCol+" from "+table+" where
"+idCol+"='"+value+"'");

Quote:
}
}

    Hope this helps.

--
               - Nicholas Paldino [.NET/C# MVP]


Quote:
> hi i have a problem concerning custom properties. i have following
property
> and the problem is when i open the designer an exception occures because
the
> values aren't known at designtime. how can i avoid this?

> is there a way to hide the property from the designer? or should i make it
> to a method?

> public string SelectedValueDBKey
> {
> get
> {
> if (Text=="")
> return "null";
> return dbConn.gettext("select "+idCol+" from "+table+" where
> "+textCol+"='"+Text+"'");
> }
> set
> {
> if (value==null)
> Text="";
> else
> Text = dbConn.gettext("select "+textCol+" from "+table+" where
> "+idCol+"='"+value+"'");
> }
> }



Sat, 25 Jun 2005 21:55:02 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Exception handling - how to know which exceptions are thrown

2. Exception errro HRESULT: 0x80131019 from the View Designer

3. Properties of a user control displayed in designer

4. Property options with Extender/Custom Designers

5. Throwing Exceptions in Constructors

6. System.Drawing.SafeNativeMethods threw an exception

7. std::list.clear() throws exceptions in .NET 2003.

8. Function that only throws an exception

9. too many controls throw exception

10. OK to throw exception from constructor?

11. __raise throws exception

12. Behavior of throw() exception specification?

 

 
Powered by phpBB® Forum Software