Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 23851 |  Welcome, Guest!   Register  Login
 Home > Forums > WPF > Comparing the Search String with the ILIST in WPF ...
Anupama96

Comparing the Search String with the ILIST in WPF

Replies: 1 | Posted by: Anupama96 on 2/6/2012 | Category: WPF Forums | Views: 536 | Status: [Member] | Points: 10  


Hi,
This is the first time i am using WPF with LINQ
I am writing the below code to load the listbox

string usageIndicator = AppEnvironment.ToUpper() == "PROD" ? "P" : "T";

using (X12837DataContext dc = new X12837DataContext(_ediConnectionstring))

{

IList<tbl837SubmissionGroupData> submissionGroups = dc.tbl837SubmissionGroupDatas.Where(s => s.UsageIndicator == usageIndicator &&
(s.SelectClaimsByDate == "Y" || s.SelectClaimsNotSent == "Y")).OrderBy(g => g.SubmissionGroupName).ToList();
lstBoxSubmissionGroup.ItemsSource = submissionGroups;
lstBoxSubmissionGroup.DisplayMemberPath = "SubmissionGroupName";
ResponseText = string.Format("{0} submission groups listed.\n", submissionGroups.Count);
}

where tbl837SubmissionGroupData is a class containing all the attributes ,
submissionGroups andsubmissionGroupName are the attributes.

now the data is like submissiongroups have [0],[1],[2],[3]
which internall contains variables...
[0] ==> id, groupname,groupid

so i want to check all the list [0][1][2][3] data to find a string suppose "mat"which is a unique value in the entire list and get its index.

for example i found mat in [2] then i want to return 2 as index

how to do that. i wrote the following code after the above code but no use i am getting nowher could u please suggest a better approach or help me with any link
IEnumerable items = lstBoxSubmissionGroup.Items;
foreach (object obj in items)
{
string val = obj as string;
if ((!string.IsNullOrEmpty(val)) && val.Contains(searchString))
{
int id = lstBoxSubmissionGroup.Items.IndexOf(obj);
}
}

Anupama Bommaraju


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Blessyjees
Blessyjees  
Posted on: 2/7/2012 4:34:51 AM
Level: Bronze | Status: [Member] | Points: 25

Hi,

change your code like below and try

foreach (ListBoxItem item in this.listBox1.Items)

{
if (item.Content.ToString().Contains("t"))
{
int index = this.listBox1.Items.IndexOf(item);
MessageBox.Show(index.ToString());
}
}


Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Anupama96, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/20/2013 3:48:15 AM