Connection string design-time editor

I'd like to create a user control that has a connection string property that allows the user to setup a connection at design time in the same fashion as in Project settings or TableAdapters.

When a someone adds this control to their form, there will be a property called ConnectionString that when it is clicked (via the Properties grid), it will bring up the Connection Properties dialog box.

I'd like to know if this is possible using ComponentModel attributes, and if so, which one?

Thanks,

J

[538 byte] By [JRusso] at [2008-1-4]
# 1

Hi J Russo,

Try like this:

Code Snippet

namespace UserControls

{

public partial class UserControl1 : UserControl

{

public UserControl1()

{

InitializeComponent();

}

private string _connectionstring;

[RefreshProperties(RefreshProperties.All),RecommendedAsConfigurable(true), DefaultValue(""), Editor("Microsoft.VSDesigner.Data.SQL.Design.SqlConnectionStringEditor, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]

public string Connectionstring

{

get { return _connectionstring; }

set { _connectionstring = value; }

}

}

}

Hope this helps.

Regards

Rong-ChunZhang-MSFT at 2007-9-26 > top of Msdn Tech,Windows Forms,Windows Forms Designer...
# 2

I got the error message box below...

DataConnectionsServiceWrap cannot ne created without a ServerExplorer service.

Anonymous at 2007-9-26 > top of Msdn Tech,Windows Forms,Windows Forms Designer...
# 3

Hi,

Which version of IDE did you use? I use the Visual Studio 2005.

Thanks

With Regards

Rong-ChunZhang-MSFT at 2007-9-26 > top of Msdn Tech,Windows Forms,Windows Forms Designer...