user4367090
user4367090

Reputation:

How to change row numbering in property grid

I have a property grid showing a list of classes

enter image description here

now when I click on the tree dots it opens this viewer

enter image description here

Now I am required to change row numbering from 0-13 to 1-14. Is there any way to do that?

If not I can add a dummy class at 0 but then I will have to scroll down in order to hide this first 0 element

thanks

enter image description here

Upvotes: 0

Views: 79

Answers (1)

Patrick
Patrick

Reputation: 2593

This is how I would solve that:

First I identify the listBox of all elements then I select the last one and scroll on bottom

protected override CollectionForm CreateCollectionForm()
{
    CollectionForm form = base.CreateCollectionForm();
    lbx = (ListBox)form.Controls.Find("listBox", true).First();
    lbx.SelectedIndexChanged += Lst_SelectedIndexChanged;
    form.Height = 340; <-------------So that you hide the first element

    return form;
}
ListBox lbx;

private void Lst_SelectedIndexChanged(object sender, EventArgs e)
{
    lbx.SelectedIndexChanged -= Lst_SelectedIndexChanged;

    int visibleItems = lbx.ClientSize.Height / lbx.ItemHeight;
    lbx.TopIndex = Math.Max(lbx.Items.Count - visibleItems + 1, 0);
}

Upvotes: 0

Related Questions