troubleshooting Question

How can i cast contents of a list into 2 fields withing a Grid

Avatar of Olukayode Oluwole
Olukayode OluwoleFlag for Canada asked on
C#* DataGridView
7 Comments1 Solution54 ViewsLast Modified:
I have a Grid called dgvDetailsTables in my C# application

I need to populated 2 columns of the Grid   (Department and Division)

from a list . Currently A click puts the whole record into the Department column.

The code below loads the Combo within the Grid  and also gives me  a list within the Combo  to select from

 dgvcmbDepartment.DataSource = GlobalConfig.Connection.GetResponsibleMgr_All();
 dgvcmdDepartment.DisplayMember = "FullCodeName"


 public string FullCodeName => $"{divisioncode}  {deptcode }  { deptdesc} ";


See  the Grid with the Combo loaded  elements of "FullCodeName"

Combo Withing the Grid already having a list"

I now need to cast the content of "FullCodeName"  so that the first element   goes into column 6  (Division )

and the Second element goes into coulmn7 (Department)

I am trying to Cast the content of FullCodeName such that i can achieve this goal

but i know my cast statement has an error  ( See Code below )

Wrong  Cast  Statement
Can someone please help to look at the Cast statement and how i should modify it

so that on Click event  I get the 2 columns into the grid columns desired.

Thanks


Olukay
ASKER CERTIFIED SOLUTION
Chinmay Patel
Chief Technology Ninja
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros