2017-05-23 14 views
0

郵便番号検索を行う既存のWebサービスを使用しています。リストボックスに値:「ID」、「テキスト」、「ハイライト」、「カーソル」、 「説明」、「次へ」。ID &次の paramの特定の文字列値にアクセスして、後で検証する必要があります。リストボックスをクリックすると、特定のデータを保存しておき、必要な2つの情報にアクセスします。リストボックスの特定の行の情報にアクセスして後で使用するにはどうすればよいですか?リストに格納された特定の情報を取得する方法

try 
{ 
    int myMaxResultValue = (int)nud_MaxResults.Value; 
    int myMaxSuggestValue = (int)nud_MaxSuggestions.Value; 
    findResults = objBvSoapClient.CapturePlus_Interactive_Find_v2_10("Dak4-KZ62-AAdd87-X55", txt_Search.Text, txt_LastId.Text, cb_SearchFor.Text, text_Country.Text, text_LanguagePreference.Text, myMaxResultValue, myMaxSuggestValue); 

    if (txt_Search.Text.Length <= 2)// if less than two letters are entered nothing is displayed on the list. 
    { 
     ls_Output.Items.Clear();// Clear LstBox 
     ls_Output.Items.Add(String.Format(allDetails, "ID", "Text", "Highlight", "Cursor", "Description", "Next")); 
     MessageBox.Show("Please enter more than 2 Chars!!"); 
    } 
    else if (txt_Search.Text.Length >= 3)// if greater than or equal to 3 letters in the search box continue search. 
    { 
     // Get Results and store in given array. 
     foreach (var items in findResults) 
     { //Loop through our collection of found results and change resulting value. 
      ls_Output.Items.Add(String.Format(allDetails, items.Id, items.Text.ToString(), items.Highlight, items.Cursor, items.Description, items.Next)); 
     } 
    } 
} 
+0

のようにアクセスすることができますなぜあなたは、クラスPostCodeSearchResultのオブジェクトを使用していませんか? –

+0

@devil_coder mycuレントサービスからアドレスを取得済みです。リストボックスの特定の行の情報にアクセスし、後でそれを使用する方法が見つかりました – whatdoyouNeedFromMe

+0

しようとしましたint index = listBox1.FindString検索文字列); ? –

答えて

1

あなたのstring.Formatには、文字列の変数がありません。これはもっと似ているはずです

出力は「IDは30です。こんにちは。」です。

あなたの質問に答えるには、それを解析して必要な部分を引き出す必要があります。これを行うにはregex.splitを使用することができます。例えば、それはスペースに区切られています場合は、この

string[] data = Regex.Split(operation, @"\s+"); 

ような何かを行うことができます次に、この

string required = data[3]; 
関連する問題