SelectionList.SelectType Propriedade
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Obtém ou define o tipo de interface do usuário usada para fornecer uma seleção da interface do usuário. Deve ser do tipo ListSelectType. O valor padrão é DropDown. Esta API está obsoleta. Para obter informações sobre como desenvolver aplicativos móveis ASP.NET, consulte Aplicativos Móveis & Sites com ASP.NET.
public:
property System::Web::UI::MobileControls::ListSelectType SelectType { System::Web::UI::MobileControls::ListSelectType get(); void set(System::Web::UI::MobileControls::ListSelectType value); };
[System.ComponentModel.Bindable(true)]
public System.Web.UI.MobileControls.ListSelectType SelectType { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.SelectType : System.Web.UI.MobileControls.ListSelectType with get, set
Public Property SelectType As ListSelectType
Valor da propriedade
Tipo de interface do usuário usada para fornecer uma seleção da interface do usuário.
- Atributos
Exemplos
O exemplo de código a seguir mostra como usar o SelectedIndexChanged evento . Ele também mostra como usar a Rows propriedade no postback para expandir a lista.
Observação
O exemplo de código a seguir usa o modelo de código de arquivo único e pode não funcionar corretamente se copiado diretamente em um arquivo code-behind. Este exemplo de código deve ser copiado para um arquivo de texto vazio que tenha uma extensão de .aspx. Para obter mais informações, consulte ASP.NET Visão geral da sintaxe de página dos Web Forms.
<%@ Page Language="C#"
Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<script runat="server">
public void Page_Load(Object sender, EventArgs e)
{
if (!IsPostBack)
{
// Create data for the list
ArrayList arr = new ArrayList();
arr.Add (new
Task ("Verify transactions", "Done"));
arr.Add (new
Task ("Check balance sheet", "Scheduled"));
arr.Add (new
Task ("Call customer", "Done"));
arr.Add (new
Task ("Issue checks", "Pending"));
arr.Add (new
Task ("Send report", "Pending"));
arr.Add (new
Task ("Attend meeting", "Scheduled"));
// Set properties for the list
SelList1.SelectType =
ListSelectType.ListBox;
SelList1.Wrapping = Wrapping.NoWrap;
SelList1.DataValueField = "Status";
SelList1.DataTextField = "TaskName";
SelList1.Rows = 3;
// Bind the list to the data
SelList1.DataSource = arr;
SelList1.DataBind ();
Label1.Text = "Select an item and click the button.";
Label2.Text = "Tasks are arranged by priority";
}
}
void ShowStatus(Object sender, EventArgs e)
{
string statusSpec = "Status: {0} is {1}";
string prioSpec = "Priority: {0}";
// Expand the list to show all items
SelList1.Rows = SelList1.Items.Count;
// Display the status
Label1.Text = String.Format(statusSpec,
SelList1.Selection.Text,
SelList1.Selection.Value);
// Display the priority
Label2.Text = String.Format(prioSpec,
(SelList1.SelectedIndex + 1));
}
// Custom class for the task data
class Task
{
private String _TaskName;
private String _Status;
public Task(String TaskName, String Status)
{
_TaskName = TaskName;
_Status = Status;
}
public String TaskName { get { return _TaskName; } }
public String Status { get { return _Status; } }
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<mobile:Form runat="server" id="Form1">
<mobile:Label runat="server" id="Label1" />
<mobile:Label runat="server" id="Label2" />
<mobile:SelectionList runat="server" id="SelList1"
OnSelectedIndexChanged="ShowStatus" />
<mobile:Command ID="Command1" runat="server"
Text="Show Status" />
</mobile:Form>
</body>
</html>
<%@ Page Language="VB"
Inherits="System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<script runat="server">
Public Sub Page_Load(ByVal sender As Object, _
ByVal e As EventArgs)
If Not IsPostBack Then
' Create data for the list
Dim arr As New ArrayList()
arr.Add(New _
Task("Verify transactions", "Done"))
arr.Add(New _
Task("Check balance sheet", "Scheduled"))
arr.Add(New _
Task("Call customer", "Done"))
arr.Add(New _
Task("Issue checks", "Pending"))
arr.Add(New _
Task("Send report", "Pending"))
arr.Add(New _
Task("Attend meeting", "Scheduled"))
' Set properties for the list
SelList1.SelectType = _
ListSelectType.ListBox
SelList1.Wrapping = Wrapping.NoWrap
SelList1.DataValueField = "Status"
SelList1.DataTextField = "TaskName"
SelList1.Rows = 3
' Bind the list to the data
SelList1.DataSource = arr
SelList1.DataBind ()
Label1.Text = "Select an item and click the button."
Label2.Text = "Tasks are arranged by priority"
End If
End Sub
Private Sub ShowStatus(ByVal sender As Object, ByVal e As EventArgs)
Const statusSpec As String = "Status: {0} is {1}"
Const prioSpec As String = "Priority: {0}"
' Expand the list to show all items
SelList1.Rows = SelList1.Items.Count
' Display the status
Label1.Text = String.Format(statusSpec, _
SelList1.Selection.Text, _
SelList1.Selection.Value)
' Display the priority
Label2.Text = String.Format(prioSpec, _
(SelList1.SelectedIndex + 1))
End Sub
' Custom class for the task data
Class Task
Private _TaskName As String
Private _Status As String
Public Sub New(ByVal TaskName As String, _
ByVal Status As String)
_TaskName = TaskName
_Status = Status
End Sub
Public ReadOnly Property TaskName() As String
Get
Return _TaskName
End Get
End Property
Public ReadOnly Property Status() As String
Get
Return _Status
End Get
End Property
End Class
</script>
<html xmlns="http:'www.w3.org/1999/xhtml" >
<body>
<mobile:Form runat="server" id="Form1">
<mobile:Label runat="server" id="Label1" />
<mobile:Label runat="server" id="Label2" />
<mobile:SelectionList runat="server" id="SelList1"
OnSelectedIndexChanged="ShowStatus" />
<mobile:Command ID="Command1" runat="server"
Text="Show Status" />
</mobile:Form>
</body>
</html>
Comentários
Um SelectionList objeto pode ser renderizado como uma CheckBox
lista , DropDown
, MultiSelectListBox
ListBox
, ou Radio
, dependendo do dispositivo de destino. O tipo de seleção também afeta se o controle permite que o usuário selecione vários itens. As MultiSelectListBox
configurações e CheckBox
permitem várias seleções; outras configurações permitem apenas uma única seleção. Os tipos de seleção são mostrados na tabela a seguir.
ListSelectType valor |
Descrição | Multiselect |
---|---|---|
CheckBox |
Renderiza os itens da lista com caixas de seleção e várias funcionalidades de seleção. | Yes |
DropDown |
Renderiza os itens de lista em uma caixa de listagem suspensa. | Não |
ListBox |
Renderiza os itens de lista em uma caixa de listagem. | Não |
MultipleSelectionListBox |
Renderiza os itens de lista em uma caixa de listagem com várias funcionalidades de seleção. | Yes |
Radio |
Renderiza os itens de lista como opções. | Não |
Aplica-se a
Confira também
Comentários
https://aka.ms/ContentUserFeedback.
Brevemente: Ao longo de 2024, vamos descontinuar progressivamente o GitHub Issues como mecanismo de feedback para conteúdos e substituí-lo por um novo sistema de feedback. Para obter mais informações, veja:Submeter e ver comentários