【发布时间】:2017-05-23 10:32:29
【问题描述】:
我正在使用一个现有的网络服务,它进行邮政编码搜索,然后将值存储在列表框中:“ID”、“文本”、“突出显示”、“光标”、“描述”、“下一个"。 我需要尝试访问一个特定的字符串值,即 ID & Next 参数,并在以后使用它进行验证。当我单击列表框时,我希望存储特定数据,然后访问我需要的两条信息。如何访问列表框特定行的信息并在以后使用?
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));
}
}
}
【问题讨论】:
-
为什么不使用 PostCodeSearchResult 类的对象?
-
@devil_coder 我已经从 mycu rrent 服务获得了地址,我需要做的是找出如何访问列表框特定行的信息并在以后使用它
-
你试过 int index = listBox1.FindString(searchString); ?
标签: c# winforms collections