We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

ListBoxSelectionMode=1 problem

I have a virtual grid that works somewhat like the VirtTreeGrid sample. I have set the selection mode as follows: grid.ListBoxSelectionMode = SelectionMode.One; grid.ForceCurrentCellMoveTo = true; For some reason, the entire row is selected only when I use the mouse to click in a cell or when I move horizontally within the same row. As soon as I use the mouse to move to another row, the full-row selection stops working. If I start moving around in the new row, the cells I was on are painted using the "selected" color (i.e. with a gray background). I have been unable to figure out what''s causing this problem. I tried commenting out all the code that is executed in the QueryCellInfo handler, but that didn''t correct the problem. Any thoughts where I should look? By the way, I have two data-bound grids displayed at the same time, both using "One" as the ListBoxSelection mode. They work just fine. Thanks, Andy

9 Replies

Administrator March 19, 2004 10:15 AM UTC

I mis-stated part of the problem. The problem occurs only when I use the keyboard to move to another row. Using the mouse to click on another row works fine. Sorry for the confusion. >I have a virtual grid that works somewhat like the VirtTreeGrid sample. I have set the selection mode as follows: > >grid.ListBoxSelectionMode = SelectionMode.One; >grid.ForceCurrentCellMoveTo = true; > >For some reason, the entire row is selected only when I use the mouse to click in a cell or when I move horizontally within the same row. As soon as I use the mouse to move to another row, the full-row selection stops working. If I start moving around in the new row, the cells I was on are painted using the "selected" color (i.e. with a gray background). > >I have been unable to figure out what''s causing this problem. I tried commenting out all the code that is executed in the QueryCellInfo handler, but that didn''t correct the problem. > >Any thoughts where I should look? > >By the way, I have two data-bound grids displayed at the same time, both using "One" as the ListBoxSelection mode. They work just fine. > >Thanks, >Andy

Administrator March 19, 2004 10:37 AM UTC

I added ListBoxSelectionMode = SelectionMode.One to the VirtTreeGridSample, and did not have a problem moving the selected row with the arrow keys (using 2030). Are you handling any events that might affect the current cell activating or current cell moving? Can you modify the VirtTreeGrid sample to show the problem?

Administrator March 19, 2004 01:52 PM UTC

Clay, Here''s the setup for the grid in question. I''ve tried commenting out the handler for the CurrentCellMoved event. I''ve also commented out the code inside the QueryCellInfo handler. Still have the problem... this.browserGrid = new sfGrid.GridControl(); this.browserGrid.BeginInit ( ); this.browserGrid.Name="browserGrid"; this.browserGrid.Text="browserGrid"; this.browserGrid.BorderStyle=System.Windows.Forms.BorderStyle.Fixed3D; this.browserGrid.Size = new System.Drawing.Size(0,0); this.browserGrid.Dock = System.Windows.Forms.DockStyle.Fill; this.browserGrid.ColCount = 0; this.browserGrid.RowCount = 0; this.browserGrid.NumberedColHeaders = false; this.browserGrid.NumberedRowHeaders = false; this.browserGrid.Rows.HeaderCount = 1; this.browserGrid.Rows.FrozenCount = 1; this.browserGrid.ListBoxSelectionMode = SelectionMode.One; this.browserGrid.ForceCurrentCellMoveTo = true; this.browserGrid[-1,-1].ReadOnly = true; // the browser grid cells are non-editable at all times this.browserGrid.ResizeColsBehavior = (((Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.ResizeSingle | Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.InsideGrid) | Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.OutlineHeaders) | Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.OutlineBounds); this.Controls.AddRange( new System.Windows.Forms.Control[] { this.browserGrid } ); this.browserGrid.CommandStack.Enabled = false; this.browserGrid.CellModels.Add ("TreeCellModel", new TreeCellModel(this.browserGrid.Model)); this.browserGrid.ResizingColumns += new sfGrid.GridResizingColumnsEventHandler(this.browserGrid_ResizingColumns); this.browserGrid.CellButtonClicked += new sfGrid.GridCellButtonClickedEventHandler(this.browserGrid_CellButtonClicked); this.browserGrid.QueryCellInfo += new sfGrid.GridQueryCellInfoEventHandler(GridQueryCellInfo); this.browserGrid.QueryRowCount += new sfGrid.GridRowColCountEventHandler(GridQueryRowCount); this.browserGrid.QueryRowHeight += new sfGrid.GridRowColSizeEventHandler(GridQueryRowHeight); this.browserGrid.QueryColCount += new sfGrid.GridRowColCountEventHandler(GridQueryColCount); this.browserGrid.QueryColWidth += new sfGrid.GridRowColSizeEventHandler(GridQueryColWidth); this.browserGrid.QueryCoveredRange += new sfGrid.GridQueryCoveredRangeEventHandler(GridQueryCoveredRange); this.browserGrid.CurrentCellMoved += new sfGrid.GridCurrentCellMovedEventHandler (GridCurrentCellMoved); >I added ListBoxSelectionMode = SelectionMode.One to the VirtTreeGridSample, and did not have a problem moving the selected row with the arrow keys (using 2030). > >Are you handling any events that might affect the current cell activating or current cell moving? > >Can you modify the VirtTreeGrid sample to show the problem?

Administrator March 19, 2004 01:58 PM UTC

I also modified the VirtTreeGrid sample but so far cannot figure out how to duplicate the problem in that sample. I guess if I could figure out how to duplicate it I would know what my problem was... >Clay, > >Here''s the setup for the grid in question. I''ve tried commenting out the handler for the CurrentCellMoved event. I''ve also commented out the code inside the QueryCellInfo handler. Still have the problem... > > >this.browserGrid = new sfGrid.GridControl(); >this.browserGrid.BeginInit ( ); >this.browserGrid.Name="browserGrid"; >this.browserGrid.Text="browserGrid"; >this.browserGrid.BorderStyle=System.Windows.Forms.BorderStyle.Fixed3D; >this.browserGrid.Size = new System.Drawing.Size(0,0); >this.browserGrid.Dock = System.Windows.Forms.DockStyle.Fill; >this.browserGrid.ColCount = 0; >this.browserGrid.RowCount = 0; >this.browserGrid.NumberedColHeaders = false; >this.browserGrid.NumberedRowHeaders = false; >this.browserGrid.Rows.HeaderCount = 1; >this.browserGrid.Rows.FrozenCount = 1; >this.browserGrid.ListBoxSelectionMode = SelectionMode.One; >this.browserGrid.ForceCurrentCellMoveTo = true; >this.browserGrid[-1,-1].ReadOnly = true; // the browser grid cells are non-editable at all times >this.browserGrid.ResizeColsBehavior = (((Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.ResizeSingle | Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.InsideGrid) > | Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.OutlineHeaders) > | Syncfusion.Windows.Forms.Grid.GridResizeCellsBehavior.OutlineBounds); > this.Controls.AddRange( new System.Windows.Forms.Control[] { this.browserGrid } ); > this.browserGrid.CommandStack.Enabled = false; > this.browserGrid.CellModels.Add ("TreeCellModel", new TreeCellModel(this.browserGrid.Model)); >this.browserGrid.ResizingColumns += new sfGrid.GridResizingColumnsEventHandler(this.browserGrid_ResizingColumns); >this.browserGrid.CellButtonClicked += new sfGrid.GridCellButtonClickedEventHandler(this.browserGrid_CellButtonClicked); >this.browserGrid.QueryCellInfo += new sfGrid.GridQueryCellInfoEventHandler(GridQueryCellInfo); >this.browserGrid.QueryRowCount += new sfGrid.GridRowColCountEventHandler(GridQueryRowCount); >this.browserGrid.QueryRowHeight += new sfGrid.GridRowColSizeEventHandler(GridQueryRowHeight); >this.browserGrid.QueryColCount += new sfGrid.GridRowColCountEventHandler(GridQueryColCount); >this.browserGrid.QueryColWidth += new sfGrid.GridRowColSizeEventHandler(GridQueryColWidth); >this.browserGrid.QueryCoveredRange += new sfGrid.GridQueryCoveredRangeEventHandler(GridQueryCoveredRange); >this.browserGrid.CurrentCellMoved += new sfGrid.GridCurrentCellMovedEventHandler (GridCurrentCellMoved); > > > >>I added ListBoxSelectionMode = SelectionMode.One to the VirtTreeGridSample, and did not have a problem moving the selected row with the arrow keys (using 2030). >> >>Are you handling any events that might affect the current cell activating or current cell moving? >> >>Can you modify the VirtTreeGrid sample to show the problem?

Administrator March 19, 2004 02:03 PM UTC

What happens if you comment out the QueryCoveredRange handler? If that does not affect this probelm, then try commenting out the this.browserGrid.ForceCurrentCellMoveTo = true; this.browserGrid[-1,-1].ReadOnly = true; // the browser grid cells are non-editable at all times lines.

Administrator March 23, 2004 11:23 AM UTC

I tried commenting out everything except for the 3 required handlers for a virtual grid (QueryCellInfo, ColCount, RowCount). I also commented out the normal handling of those messages and just had the col and row counts return 10 and the CellInfo handler just put the cell coordinate into the Style.Text field. The row-painting of the current row is still not working correctly. Interestingly, if I use the arrow-keys to move to the top of the grid and then hit the up arrow key one extra time, then the top row is highlighted correctly. The same happens if I move to the bottom of the grid. Pressing the down-arrow one extra time causes the last row to be highlighted. Very odd. I should point out that the grid control is actually wrapped inside a user-control-derived class. The wrapped class is then added to a tab-page. I created a new test app that creates the grid control inside a UserControl-derived class and then drops an instance of that class onto a tab page. The row selection works fine in the test app. Right now, I''m at a loss as to what the difference is between my app and the test app that would explain the strange row-selection behavior. >What happens if you comment out the QueryCoveredRange handler? > >If that does not affect this probelm, then try commenting out the > >this.browserGrid.ForceCurrentCellMoveTo = true; >this.browserGrid[-1,-1].ReadOnly = true; // the browser grid cells are non-editable at all times > >lines.

Administrator March 23, 2004 11:25 AM UTC

Clay, Should I move this discussion over to Direct-Trac? I''m not sure that the problem I''m seeing (or it''s resolution) is particularly useful to anyone else. Also, I''m wondering if you would be willing to take at look at the problem via a Placeware session that I could set up so you could see what''s happening first hand. Thanks, Andy >I tried commenting out everything except for the 3 required handlers for a virtual grid (QueryCellInfo, ColCount, RowCount). I also commented out the normal handling of those messages and just had the col and row counts return 10 and the CellInfo handler just put the cell coordinate into the Style.Text field. > >The row-painting of the current row is still not working correctly. > >Interestingly, if I use the arrow-keys to move to the top of the grid and then hit the up arrow key one extra time, then the top row is highlighted correctly. The same happens if I move to the bottom of the grid. Pressing the down-arrow one extra time causes the last row to be highlighted. Very odd. > >I should point out that the grid control is actually wrapped inside a user-control-derived class. The wrapped class is then added to a tab-page. > >I created a new test app that creates the grid control inside a UserControl-derived class and then drops an instance of that class onto a tab page. The row selection works fine in the test app. Right now, I''m at a loss as to what the difference is between my app and the test app that would explain the strange row-selection behavior. > > >>What happens if you comment out the QueryCoveredRange handler? >> >>If that does not affect this probelm, then try commenting out the >> >>this.browserGrid.ForceCurrentCellMoveTo = true; >>this.browserGrid[-1,-1].ReadOnly = true; // the browser grid cells are non-editable at all times >> >>lines.

Administrator March 23, 2004 12:39 PM UTC

Is the problem strictly a refresh problem? ie., When you do not correctly see the selection, if you drag the window off/on the screen so the grid is forced to repaint, it paints the selection properly. If so, you might try setting grid.Model.Options.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshRow; Remote debugging is generally considered consulting, and would have to be arranged through sales. Feel free to open a Direct Trac incident, but without a sample showing the problem, it will be difficult to home in on what is causing this behavior.

Administrator March 23, 2004 02:30 PM UTC

Clay, I finally figured out what the problem was. At the beggining of where I set a bunch of properties for the grid control, I do a BeginInit(). But somewhere along the line, the EndInit() call got deleted. Once I corrected that, the problem went away. >Is the problem strictly a refresh problem? ie., When you do not correctly see the selection, if you drag the window off/on the screen so the grid is forced to repaint, it paints the selection properly. > >If so, you might try setting > >grid.Model.Options.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshRow; > > >Remote debugging is generally considered consulting, and would have to be arranged through sales. > >Feel free to open a Direct Trac incident, but without a sample showing the problem, it will be difficult to home in on what is causing this behavior. > >
Loader.
Live Chat Icon For mobile
Up arrow icon