c# - Put pictures in buttons -


i new forum , programming. have advised developer community clarify doubts. apologize because english not good, have use google translator , possibly text not perfect, , lack of information on part. i've been searching question before posting message, have not found anything.

i want put images in buttons, far have managed make query in show in listbox addresses images want put buttons.

        var obtenerimagen = (from n in basededatos.tablaproductos                                             select n.imagenproducto);                                    listbox1.itemssource = obtenerimagen; 

now idea put images on buttons query.

        imagesourceconverter conversor = new imagesourceconverter();          image1.source = (imagesource)conversor.convertfromstring(obtenerimagen);  /**/          image1 = obtenerimagen.firstordefault();  /**/ 

this gives me following error lines: (/**/)

  • argument 1: cannot convert 'system.linq.iqueryable' 'string'
  • cannot implicitly convert type 'string' 'system.windows.controls.image'
  • the best overloaded method match 'system.componentmodel.typeconverter.convertfromstring(string)' has invalid arguments

what doing wrong?

your object obtenerimagen object of type iqueryable.

maybe should use:

var obtenerimagen = (from n in basededatos.tablaproductos                                             select n.imagenproducto).tolist();  

then have list of strings. can first-element example calling:

string imagesource = obtenerimagen.firstordefault();