You are not logged in.
This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.
Pages: 1
Topic closed
Hello!
I've been trying to adapt this awesome control to my needs, but I've run into some problems. My aim is to have a list-dropdown cell with grouping functionality. Achieving that in the existing Listbox-Dropdown would be tedious and never work as well as with a ListView, which is why I'm trying to create my own CellBody with a ListView instead. Unfortunately, the API seems to have changed quite a bit since Version 0.8.5 (where I have access to the source code) and I have no idea how to get the correct location for the control (in screen coordinates), taking into account e.g. the current scrolling. Is there an easy way to get this Information? It must have been implemented in the existing Listbox-Dropdown already, so it should be possible.
On another note: is it necessary for the Listbox in the DropdownCell to be internal/private? I would like to access e.g. its DisplayMember property, but I can't do that even when deriving from the DropdownCell. Making it protected would make things more flexible.
Thank you for any help!
Regards,
Argon
Offline
Hi Argon, thanks!
You're right. Listbox in DropdownCell is internal, it's not flexible enough.
Let me think a solution for your requirement; a way to put any custom controls like ListView in dropdown-panel instead of the internal listbox.
Getting cell position is a little complex in ReoGrid, as you pointed out that it's necessary to handle the scroll and zoom. In fact the views to show cells are abstract, a cell including its body can be displayed in two views at same time when the spreadsheet is frozen or separated, the cell actually has two or more coordinates on screen.
I'm trying to remove the concept about how to handle the position of body; just put the controls into the cell, and let ReoGrid to do everything else.
I am going to make an update release, with a sample code soon.
thanks, Jing
Last edited by Jingwood (2014-12-10 00:01:10)
Offline
How about this result?
The code looks like this:
1. Create own custom drop-down cell body
class ListViewDropdownCell : DropdownCell
{
private ListView listView;
public ListViewDropdownCell()
{
// create listview
this.listView = new ListView()
{
BorderStyle = System.Windows.Forms.BorderStyle.None,
View = View.Details,
FullRowSelect = true,
};
// set dropdown control
this.DropdownControl = listView;
// enlarge the dropdown panel
this.MinimumDropdownWidth = 300;
// add listview columns
this.listView.Columns.Add("Column 1", 120);
this.listView.Columns.Add("Column 2", 120);
// add groups and items
var group1 = listView.Groups.Add("grp1", "Group 1");
listView.Items.Add(new ListViewItem("Item 1.1") { Group = group1 });
listView.Items.Add(new ListViewItem("Item 1.2") { Group = group1 });
listView.Items.Add(new ListViewItem("Item 1.3") { Group = group1 });
var group2 = listView.Groups.Add("grp2", "Group 2");
listView.Items.Add(new ListViewItem("Item 2.1") { Group = group2 });
listView.Items.Add(new ListViewItem("Item 2.2") { Group = group2 });
listView.Items.Add(new ListViewItem("Item 2.3") { Group = group2 });
}
}
2. Create the cell on spreadsheet
worksheet["B2"] = new ListViewDropdownCell();
thanks, Jing
Offline
Hi Jing,
Thank you for your fast answer! Your solution looks great - flexible and clean. That would be more than enough for me. Did you already implement this (as I assume from the screen shot)?! That would have been extremely fast!
Can you already say when the next version / this feature will be available?
Regards Argon
Offline
Yes I've implemented it. Now I'm preparing the 0.8.8 download package, which contains this change and would be available soon.
Last edited by Jingwood (2014-12-05 17:49:56)
Offline
Hi, download is available here: http://reogrid.net/download/
In the demo project, there is the sample code 'Custom drop-down'.
Offline
Hi Jing!
Wow! I didn't expect anything that fast! Thank you for your effort - it seems to work great so far!
Regards,
Argon
Offline
Pages: 1
Topic closed