mardi 6 février 2018

ObjectListVIew c# columns

I'm trying to create a column programmatically and set it as checkbox. I'm doing it on Expanded event.

The snippet of my code is

if (qtdColumns < qtdPermissions)
                        {
                            for (int i = qtdColumns; i < qtdPermissions; i++)
                            {
                                OLVColumn aNewColumn = new OLVColumn();
                                aNewColumn.Text = string.Empty;

                                aNewColumn.AspectGetter += delegate (object x)
                                {
                                    if (((Model)x).permissions.Count() > 0)
                                    {
                                        aNewColumn.CheckBoxes = true;
                                        return permission.Label;
                                    }
                                    else
                                    {
                                        aNewColumn.CheckBoxes = false;
                                        return "";
                                    }
                                };

                                this.MyTreeListView.AllColumns.Add(aNewColumn);
                                qtdColumns++;
                            }
                        }

But the only result I get is like this:

enter image description here




Aucun commentaire:

Enregistrer un commentaire