Create Hyperlink or Picture Column with C# (Format URL as Picture)
-
29-09-2020 - |
Frage
I am creating a SharePoint list with C# and have created a "Hyperlink or Picture" field like so:
myList.Fields.add("Icon", SPFieldType.URL, true);
when I add an item to the list in SharePoint this field is displayed as a hyperlink. By editing the list settings in SharePoint, I can change the "Format URL as" option from "Hyperlink" to "Picture" and it works as desired.
How can I set the field to display as picture when creating the field programmatically?
Lösung
You need to use 'DisplayFormat`
SPFieldUrl fldURLImage = (SPFieldUrl)list.Fields.CreateNewField(SPFieldType.URL.ToString(), "Picture");
fldURLImage.DisplayFormat = SPUrlFieldFormatType.Image;
myList.Fields.Add(fldURLImage,SPFieldType.URL, true);
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit sharepoint.stackexchange