c# - GetDrive Info into Combo Box but concatenate 2 display members -


i'm trying combo box not contains drive letter volume label. i'm able 1 or other changing displaymember.

i understand need use .expression concatenate them before go combobox. i'm confused. should put getdrive table first , expression... load combobox?

here's code have 1 display member:

    cmbdestdrive.datasource = driveinfo.getdrives()        .where(d => d.drivetype == system.io.drivetype.removable).tolist();     cmbdestdrive.displaymember = "name"; 

this displays: f:\ i'd display f:\usb drive

edit: removed useless line of code.

you need select string want.

var drives = driveinfo.getdrives()             .where(d=>d.isready && d.drivetype == system.io.drivetype.removable)             .select(d => d.name + " (" + d.volumelabel + ")"  )             .tolist();  cmbdestdrive.datasource = drives; 

no need displayname


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -