Olukayode Oluwole
asked on
How can I return a part of a list to a field on the screen
I am working in a C# application
I have constituted a List with the script Below:
StaffNameListBox.DataSourc e = GlobalConfig.Connection.Ge tEmployees _All();
StaffNameListBox.DisplayMe mber = "FullStaffName";
public string FullStaffName
{
get
{
return $"{Staff_no} { Surname } {Firname }";
}
}
(See the Screen of The list below showing a record in the list
On the Click event on this record I want to return a part of the string (ie just the staff_no)
to a text box on the screen. The name of the textbox is StaffNoValue
My click event syntax is as below:
private void StaffNameListBox_Click(obj ect sender, EventArgs e)
{
StaffNoValue.Text = StaffNameListBox.ValueMemb er;
}
What I want Returned to the text box on screen is as shown below
StaffNoValue.Text = "N001"
How can I get a portion of a list returned into a field using the actual name with which the list was loaded
and not by searching for a sub string of the selected item
Thanks
Selection-From-List--11-01-2019.PNG
I have constituted a List with the script Below:
StaffNameListBox.DataSourc
StaffNameListBox.DisplayMe
public string FullStaffName
{
get
{
return $"{Staff_no} { Surname } {Firname }";
}
}
(See the Screen of The list below showing a record in the list
On the Click event on this record I want to return a part of the string (ie just the staff_no)
to a text box on the screen. The name of the textbox is StaffNoValue
My click event syntax is as below:
private void StaffNameListBox_Click(obj
{
StaffNoValue.Text = StaffNameListBox.ValueMemb
}
What I want Returned to the text box on screen is as shown below
StaffNoValue.Text = "N001"
How can I get a portion of a list returned into a field using the actual name with which the list was loaded
and not by searching for a sub string of the selected item
Thanks
Selection-From-List--11-01-2019.PNG
ASKER
Am i getting the syntax wrong ??
Cant go past StaffNameListBox.SelectedI tem
It is being flagged red
See attached
Please help with the syntax including how to cast it
Thanks
O.A. Oluwole
SelectedItemError12012019.PNG
Cant go past StaffNameListBox.SelectedI
It is being flagged red
See attached
Please help with the syntax including how to cast it
Thanks
O.A. Oluwole
SelectedItemError12012019.PNG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Worked like magic.
You made my day
Thanks
You made my day
Thanks
ASKER
Once again Thanks
Instead, try StaffNameListBox.SelectedI
That will return an "object" that you can cast to an Employee record and from there you should have access to every field on that record.