Dear all,
I am having difficulties to fix the column size in a ListView in Detail mode.
My set up code is very simple and as follow :
private void SetLisViewProduitBase()
{
ListViewDetailColumn PBaseColumn;
rlvProduitBase.ViewType = ListViewType.DetailsView;
rlvProduitBase.AutoSizeColumnsMode = ListViewAutoSizeColumnsMode.None;
rlvProduitBase.HeaderHeight = 18;
rlvProduitBase.Font = new Font(rlvProduitBase.Font, FontStyle.Regular);
rlvProduitBase.ShowCheckBoxes = true;
rlvProduitBase.ThreeStateMode = false;
PBaseColumn = new ListViewDetailColumn("Code");
PBaseColumn.Width = 40;
rlvProduitBase.Columns.Add(PBaseColumn);
PBaseColumn = new ListViewDetailColumn("Forme");
PBaseColumn.Width = 50;
rlvProduitBase.Columns.Add(PBaseColumn);
PBaseColumn = new ListViewDetailColumn("Nom Usuel");
PBaseColumn.Width = 100;
rlvProduitBase.Columns.Add(PBaseColumn);
PBaseColumn = new ListViewDetailColumn("Nom Botanique");
PBaseColumn.Width = 100;
rlvProduitBase.Columns.Add(PBaseColumn);
PBaseColumn = new ListViewDetailColumn("Origine");
PBaseColumn.Width = 70;
rlvProduitBase.Columns.Add(PBaseColumn);
PBaseColumn = new ListViewDetailColumn("Labels");
PBaseColumn.Width = 70;
rlvProduitBase.Columns.Add(PBaseColumn);
}While empty, the columns width are displaying fine as seen on image 1.
When I connect the Datasource (as in https://docs.telerik.com/devtools/winforms/controls/listview/populating-with-data/data-binding), all columns get the same "default" size.
As you say (in the Adding Columns doc) that using a datasource will require to set the column width within the ColumnCreating event, I have tried this.
When this event is first called after defining the columns as in the previous code, I get a NullReference exception as if the columns are not defined.
If I try to create the columns them within the event and test first for column existence, I will get a column already exist exception (An item with the same key already exist).
What am I doing wrong ?
Many thanks for your answers
Patrick