This document is archived and information here might be outdated.  Recommended version.


IListDialog.AddString Method (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Framework > ESRI.ArcGIS.Framework > Interfaces > IL > IListDialog Interface > IListDialog.AddString Method
ArcGIS Developer Help

IListDialog.AddString Method

Adds a string to the list that the dialog will show. These strings will be sorted in alphabetical order.

[Visual Basic .NET]
Public Sub AddString ( _
    ByVal Choice As String _
)
[C#]
public void AddString (
    string Choice
);

Product Availability

Available with ArcGIS Desktop.

Description

 

Choice is a string that will be used as an item in the list displayed by the dialog.

 

Remarks

The AddString method is used to populate the list that is displayed in the dialog. When the dialog is displayed, the items in the list are sorted in alphabetical order.

The following code shows a list in the dialog and then reports the string associated with the selected item. You would get m_app from the hook in ICommand::OnCreate().

[C#]
IListDialog listDlg = new ListDialogClass();
listDlg.AddString("California");
listDlg.AddString("Arizona");
listDlg.AddString("Utah");
listDlg.AddString("Nevada");
if (listDlg.DoModal("The list", 0, m_app.hWnd))
{
  switch (listDlg.Choice)
  {
    case 0:
      System.Windows.Forms.MessageBox.Show("California");
      break;
    case 1:
      System.Windows.Forms.MessageBox.Show("Arizona");
      break;
    case 2:
      System.Windows.Forms.MessageBox.Show("Utah");
      break;
    case 3:
      System.Windows.Forms.MessageBox.Show("Nevada");
      break;
  }
}
else
  System.Windows.Forms.MessageBox.Show("Cancelled");


 

[Visual Basic .NET]
Dim listDlg As IListDialog = New ListDialogClass()
listDlg.AddString("California")
listDlg.AddString("Arizona")
listDlg.AddString("Utah")
listDlg.AddString("Nevada")
If listDlg.DoModal("The list", 0, m_app.hWnd) Then
 Select Case listDlg.Choice
  Case 0
   System.Windows.Forms.MessageBox.Show("California")
   Exit Select
  Case 1
   System.Windows.Forms.MessageBox.Show("Arizona")
   Exit Select
  Case 2
   System.Windows.Forms.MessageBox.Show("Utah")
   Exit Select
  Case 3
   System.Windows.Forms.MessageBox.Show("Nevada")
   Exit Select
 End Select
Else
 System.Windows.Forms.MessageBox.Show("Cancelled")
End If

See Also

IListDialog Interface