指定したテキストを格納している Text プロパティを持つ ListItem をコレクション内で検索します。
名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文
'宣言
Public Function FindByText ( _
text As String _
) As ListItem
'使用
Dim instance As ListItemCollection
Dim text As String
Dim returnValue As ListItem
returnValue = instance.FindByText(text)
public ListItem FindByText (
string text
)
public:
ListItem^ FindByText (
String^ text
)
public ListItem FindByText (
String text
)
public function FindByText (
text : String
) : ListItem
適用できません。
パラメータ
- text
検索対象のテキスト。
戻り値
text パラメータで指定されたテキストを格納している ListItem。
解説
FindByText メソッドを使用して、text パラメータで指定されたテキストを格納している Text プロパティを持つ ListItem をコレクション内で検索します。このメソッドは、大文字と小文字を区別し、カルチャに依存しない比較を実行します。このメソッドは、部分検索またはワイルドカード検索は実行しません。この検索条件を使用して項目がコレクション内で見つからない場合は、null 参照 (Visual Basic では Nothing) が返されます。
使用例
Dim myListItem As ListItem = SearchType.SelectedItem
Dim crItem As ListItem
Dim searchText As String = TextBox1.Text
If(myListItem.Value = "Name") Then
If(TextBox1.Text <> "" ) Then
Dim searchSubfirst As String = searchText.Substring(0,1)
Dim searchSubsecond As String = searchText.Substring(1)
searchText = searchSubfirst.ToUpper()+searchSubsecond.ToLower()
' Search by country or region name.
crItem = ItemCollection.FindByText(searchText)
End If
Else
'Search by country or region code.
crItem = ItemCollection.FindByValue(searchText.ToUpper())
End If
Dim str As String = "Search is successful. Match is Found.<br />"
str = str & "The results for search string '" & searchText & "' are:<br />"
str = str & "the country or region code is: " & crItem.Value & "<br />"
str = str & "the country or region name is: " & crItem.Text
' Add the string to the label.
Label1.Text = str
ListItem myListItem = SearchType.SelectedItem;
ListItem crItem = null;
String searchText = TextBox1.Text;
if(myListItem.Value == "Name")
{
if(TextBox1.Text != "")
{
String searchSubfir = searchText.Substring(0,1);
String searchSubsec = searchText.Substring(1);
searchText = searchSubfir.ToUpper()+searchSubsec.ToLower();
// Search by country or region name.
crItem = ItemCollection.FindByText(searchText);
}
}
else
{
// Search by country or region code.
crItem = ItemCollection.FindByValue(searchText.ToUpper());
}
String str = "Search is successful. Match is Found.<br />";
str =str + "The results for search string '" + searchText + "' are:<br />";
str = str + "the country or region code is " + crItem.Value + "<br />";
str = str + "the country or region name is " + crItem.Text;
// Add the string to the label.
Label1.Text = str;
ListItem myListItem = SearchType.get_SelectedItem();
ListItem crItem = null;
String searchText = TextBox1.get_Text();
if(myListItem.get_Value().Equals("Name")) {
if(!(TextBox1.get_Text().Equals(""))) {
String searchSubfir = searchText.Substring(0,1);
String searchSubsec = searchText.Substring(1);
searchText = searchSubfir.ToUpper()
+ searchSubsec.ToLower();
// Search by country or region name.
crItem = itemCollection.FindByText(searchText);
}
}
else {
// Search by country or region code.
crItem = itemCollection.FindByValue(searchText.ToUpper());
}
String str = "Search is successful. Match is Found.<br />";
str =str + "The results for search string '" + searchText
+ "' are:<br />";
str = str + "the country or region code is "
+ crItem.get_Value() + "<br />";
str = str + "the country or region name is "
+ crItem.get_Text();
// Add the string to the label.
Label1.set_Text(str);
プラットフォーム
Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition
Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。
バージョン情報
.NET Framework
サポート対象 : 3.0,2.0,1.1,1.0
参照
関連項目
ListItemCollection クラス
ListItemCollection メンバ
System.Web.UI.WebControls 名前空間
FindByValue
ListItem
ListItem.Text プロパティ