Customizing which columns and header text being displayed

The grid list looks like it would be an ideal control for a multi column listbox type control - so that we can see multiple fields of a record to allow the record to be selected.

But I don't want to display all the fields and want to change the header text.    I can do that in a Datagrid however I don't want the user to be able to select any cells - as I simply want to highlight the entire row with no cell selected - just a the entry in the listbox would do.

Can you provide any pointers to either getting the gridlist to allow customization of the fields being displayed and columns or the datagrid to not show a cell selected - only highlight an entire row.

3 Replies

AR Arulpriya Ramalingam Syncfusion Team May 21, 2020 05:39 PM UTC

Hi Spotty, 
 
Thank you for your interest in Syncfusion support. 
 
By default, the GridListColumn will show the first column alone and multicolumns can be enabled by using the MultiColumn property. To avoid loading multiple columns this can be set to false. Please make use of the below code. 
 
Example code 
 
//To disable the multiple columns. 
ListBox1.MultiColumn = false; 
 
Please let us know, if you have any other queries. 
 
Regards, 
Arulpriya 



SP Spotty May 21, 2020 06:01 PM UTC

Yes but how do i define the column headers to be different from the field names.


AR Arulpriya Ramalingam Syncfusion Team May 24, 2020 07:13 PM UTC

Hi Spotty, 
 
Thank you for the update. 
 
In order to change the header text for a column header in GridListControl, the PrepareViewStyleInfo event can be used. In that event, the Text property of GridStyleInfo can be used. Please make use of the below sample code. 
 
Example code 
 
//Event subscription 
ListBox1.Grid.PrepareViewStyleInfo += Grid_PrepareViewStyleInfo1; 
 
//Event customization. 
private void Grid_PrepareViewStyleInfo1(object sender, GridPrepareViewStyleInfoEventArgs e) 
{ 
    if (e.RowIndex == 0 && e.ColIndex == 1) 
    { 
        e.Style.Text = "Header"; 
    } 
} 
 
Please let us know, if you have any other queries. 
 
Regards, 
Arulpriya 


Loader.
Up arrow icon