Здравствуйте, Darkman_CV, Вы писали:
D_C>Подскажите, как заставить дизайрен свойств отображать не TextBox (что он сделает в данном примере), а
D_C>именно ListBox со списком имеющихся ConnectionStrings?
Пример:
в App_Code добавляете класс Relation.cs
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.ComponentModel;
/// <summary>
/// Summary description for Relation
/// </summary
namespace ControlTest
{
public class Relation : WebControl
{
private string _relation = "Unknown";
[TypeConverter(typeof(RelationConverter)), Category("Details")]
public string RelationType
{
get { return _relation; }
set { this._relation = value; }
}
internal class RelationConverter : StringConverter
{
public override StandardValuesCollection GetStandardValues(
ITypeDescriptorContext context)
{
return new StandardValuesCollection(new string[]{"Mother",
"Father", "Sister",
"Brother", "Daughter", "Son",
"Aunt", "Uncle", "Cousin"});
}
public override bool GetStandardValuesSupported(
ITypeDescriptorContext context)
{
return true;
}
public override bool GetStandardValuesExclusive(
ITypeDescriptorContext context)
{
// true - значит только выбирать, false -
// выбирать и редактировать
return true;
}
}
}
}
default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register TagPrefix="cc1" Namespace="ControlTest" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<cc1:Relation runat="server" ID="relation1" />
</div>
</form>
</body>
</html>
Выбирая контрол Relation, в propertygrid в дизайнере в категории "Details" мы видим свойство RelationType с выпадающим списком
... << RSDN@Home 1.2.0 alpha rev. 0>>