Owner-draw selected row

May 13, 2009 at 7:07 PM

Hi, I am trying to migrate from DevExpress grid to SourceGrid. I am extremely impressed with SourceGrid so far, but have some issues below. If I can resolve them, I can get rid of DevExpress for good and provide an excellent reference to SourceGrid if requested.

1) I need to custom draw selected row. Is it possible with SourceGrid? I need to draw a selected row ignoring "focused" cell. I also need to draw it in my own custom color. So the whole selected row should be solid without "gap" of the focused cell. I do not see a way to override the default "selected cell color". I inherited my View class from "SourceGrid.Cells.Views.Cell".

2) Is there a way (like an event) to detect when a "top" (grid.Rows.FirstVisibleScrollableRow) row gets changed during user scroll?

3) Is there a way to remove a scroll bar from grid permanently? I found method "SetVScrollBarVisible(bool value)", but scroll bars are restored after grid is invalidated.

4) Is there a way to scroll view to a specific row without making it focused. The row specified should become the Top row of the visible view. (set grid.Rows.FirstVisibleScrollableRow value somehow).

Your help is appreciated

Coordinator
May 14, 2009 at 11:05 AM

Hi,

That's interesting to hear that  you want to migrate from DevExpress, since i know it is a superior grid.


1. Custom draw should be possible, you can custom draw cell by overriding IView.DrawCell method. Focus is probably (i am not sure 100%) drawn as a decorator (GridVirtual.cs:1502).   There is a DecoratorSelection class.  

Maybe you could create your own custom DecoratorSelection class and just not draw selection, when you don't need it.

2. what do you mean a row gets "changed" ?

3.  At the moment you can not achieve this.   If that's a necessary functionality, we could add it, it's not that difficult to implement it.

4. Possible:

grid1.Selection.FocusStyle = FocusStyle.None;
grid1.CustomScrollPosition = new Point(15, 15);

May 15, 2009 at 4:36 PM

Darius, you are very humble. I fixed drawing problem. All I had to do is to clear Decorators collection.

There are several reasons I do not like DevExpress:

1) It is a very big a bulky. It takes couple seconds to load and hard to distribute because of its size -  7 MEG

2) It has major problems loading large data sets. If you load 200K items in it, it will have some major performance problems.

3) Pricing is quite steep.

There are couple features that are missing in the SourceGrid however. It is related to questions 2)-4) in my original post.

1) I have a window that has 2 grids displayed size by side: one on the left, grid A and one on the right grid B. Both A and B have the same number of rows. The rows in A and B are related and should be shown side by side meaning that if user scrolls to the row N in A, B should also scroll to row N. Vertical scroll bar in the grid A (left one) should be removed because grid B controls vertical scroll. The way it is implemented is DevExpress is that I handle "TopRowChanged" event that is fired when top row index changes and I then set "TopRowIndex" in the other grid. I also call VertScrollVisibility = ScrollVisibility.Never to remove scroll bar in grid A.

What it looks to me is that scrolling functionality in SourceGrid is tied to the scroll bar, so the above functionality cannot be easily implemented. Is it correct? I managed to remove the scroll bar by calling SetVScrollBarVisible, but the side effect of it is that if I have more rows that are visible, I cannot scroll down using keyboard. Also, row positioning using CustomScrollPosition relies on the scroll bar to be present and it is not acceptable. Do you have any ideas on how to work around this besides combing grids into one?

2) Do you plan to implement column reordering using drag and drop? It is somewhat important functionality for us. I think you mentioned that it is in the works...

3) This is very minor, but horizontal scroll should use pixel increment, not column width increment. I frequently repaint grid using RowChanged event. If I scroll right and the RowChanged is invoked while I do it, I see some scroll bar redrawing problems: the scroll thum changes width for some reason.

May 15, 2009 at 9:24 PM

Darius, I figured out how to resolve issue 1. I had to set the scroll bar's width to 1 and Visible to false, so it is still displayed, but so narrow, it is effectively removed. It will be nice long term not to rely on the scroll bar for the row positioning, like DevExpress does. If you could clarify at least question 2 in my previous post, I will appreciate it.

Coordinator
May 16, 2009 at 1:58 PM

I am very intrigued to hear, that DevExpress has performance problems!  In my company, we are actually thinking of moving from SourceGrid to DevExpress, because DevExpress shows nice performance, at least what i and other developers saw in examples. Of course, i must admit, none of the samples had more than 1k rows.

Have you tried 200k rows with SourceGrid? How does it perform?

 

2) About drag and drop - there was support for this in older versions of SourceGrid support for drag and drop out of the box, but at the moment it is not working. The original author of SourceGrid dropped support for it. I speculate that this was done simply because the code changed, and there was simply no time to re-implement it again.

Personally, i too have no time to implement it (i have a full time job, and managing SourceGrid does take some time even without any programming tasks). However, it should not be very difficult to implement it, and I will provide any needed information and support needed.

I've searched through the code and found, that in frmSample1.cs:245 and in frmSample43.cs:135 there is old reference to drag and drop controllers.

Great! I actually see that in the folder \SourceGrid4\SourceGrid\Controllers\ there are files SelectionDrag.cs and SelectionDrop.cs 

You could take those files as a reference. These files are not included at all in the project, and i will probably delete these soon from the repository.

 

3) About horizontal scrolling in pixels i actually did not understand what is happening. If possible, a real working example with code to reproduce this behaviour would be best.

 

Side note: i'am thinking of maybe to rewrite scroll bar logic to make scrolling increment by pixels, not full rows and full columns. The result would be a smooth transition from one row / column to another. Windows DataGridView is capable of that, and looks really nice. When i saw this behaviour in SourceGrid, it did not impress me very much.

 

 

May 21, 2009 at 8:53 PM

Personally, I would not use expensive components unless it is absolutely necessary. I do a lot of Java programming and find JTable to be the best designed grid available of all I have used. SourceGrid reminds me of it a bit.

DevExpress has some tree-like greed support that is hard to reproduce, but overall it is very bloated and heavy. Source grid does not have problem loading 200,000 rows.

2) Thanks for the research. I do not have time to work on this one now. The project I am doing is experimental and we do not have a client yet. We may be able to pay in the future for some added features, but it is too early to discuss it now.

3) I personally like row-increment for the vertical scroll and pixel increment for the horizontal scroll (this is what DevExpress grid does). I can send you sample to demonstrate the problem, but it is somewhat minor.

Coordinator
May 25, 2009 at 1:50 PM

I am glad to hear SourceGrid performs well with 200k rows. There are some performance issues still, but they will be solved, as the solutions are already clear.


3) The best solution would be to support both row / column and pixel scrolling, if that's tecnically possible.

I  just checked how SharpDevelop does that, and in "Search results" dialog box, text is scrolled on a row basis, while in the main text area, text is scrolled by pixel vertically, and horizontally by characters.

Somewhat strange behaviour, i did not expect to see this.