AD
Administrator
Syncfusion Team
December 31, 2004 09:11 AM UTC
In a dynamic splitter you need to subscribe to event in PaneCreated and unsubscribe to event in PaneClosing. Take a look at this KB.
http://64.78.18.34/Support/article.aspx?id=580
DB
David Bosak
January 1, 2005 04:44 AM UTC
I did as your direction. However, splitter is lost.
Please help!
AD
Administrator
Syncfusion Team
January 1, 2005 07:03 AM UTC
We ship many samples using splitters. Do you see the problem you are having in any of these samples?
If you can upload a sample project showing the problem you are having, we can try to debug it.
AD
Administrator
Syncfusion Team
January 1, 2005 08:15 AM UTC
Here is a minimal sample that handles the click events and does not seem to have the problem you described for me in 2.1.0.9. Do you see the problem in this sample?
http://www.syncfusion.com/forums/Uploads/GDBG_RecNav_Events.zip
DB
David Bosak
January 4, 2005 08:13 AM UTC
I did OK.
However, there are one problem:
- If I move splitter bar toward right-hand and out of the GDBG, the original grid will be kept, events run OK.
- If I move splitter bar toward left-hand and out of the GDBG, the new grid will keep, events of the original grid not kept. How to fix it? How to display the orginal GDBG instead of new grid in this case.
Please help!
Thanks,
AD
Administrator
Syncfusion Team
January 4, 2005 09:11 AM UTC
This does not happen in the sample I uploaded, does it?
The only way I can help is if you upload a sample showing the problem.
AD
Administrator
Syncfusion Team
January 4, 2005 09:21 AM UTC
If for some reason, you cannot upload a sample, then post code so I can see what you are doing.
1) The code where you subscribe to the PaneCreated and PaneClosing events.
2) Your event handlers for the PaneCreated and PaneCLosing events.
3) The code where you subscribe to the grid events initially.
DB
David Bosak
January 4, 2005 11:54 PM UTC
Hi Clay,
I cannot open the attachment link.
1. FrmAssociates.cs with two child classes: FrmAssociates and MyGridDataBoundGrid
public class MyGridDataBoundGrid : GridDataBoundGrid {
private bool inColSelections = false;
public MyGridDataBoundGrid(GridDataBoundGridModel model):base(model)
{
}
public MyGridDataBoundGrid()
{
}
///
/// Clean up any resources being used.
///
///
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e) {
int row, col;
Point pt = this.PointToClient(Control.MousePosition);
bool onColHeader = this.PointToRowCol(pt, out row, out col, -1) && row == 0;
if( onColHeader && !inColSelections) {
this.ListBoxSelectionMode = SelectionMode.None;
}
else if(!onColHeader && inColSelections)
{
GridCurrentCell cc = this.CurrentCell;
if (cc.RowIndex > 0)
{
this.ListBoxSelectionMode = SelectionMode.One;
inColSelections = false;
}
}
base.OnMouseDown(e);
}
protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e) {
base.OnMouseUp(e);
int row, col;
Point pt = this.PointToClient(Control.MousePosition);
if(this.PointToRowCol(pt, out row, out col, -1) && row == 0) {
if(!inColSelections)
inColSelections = true;
else
{
inColSelections = false;
}
}
else
{
GridCurrentCell cc = this.CurrentCell;
if (cc.RowIndex > 0)
{
this.ListBoxSelectionMode = SelectionMode.One;
inColSelections = false;
}
}
}
}
2. In FrmAssociates class, I use GDBG is dgrSearchResult which is inherited from MyGridDataBoundGrid instead of GDBG:
private Syncfusion.Windows.Forms.Grid.GridRecordNavigationControl gridRecordNavigationControl1;
private NavigationPreference.MyGridDataBoundGrid dgrSearchResult;
3. rightStandarSearchGrid is
private GridDataBoundGrid rightStandardSearchGrid;
private void gridRecordNavigationControl1_PaneCreated(object sender, Syncfusion.Windows.Forms.SplitterPaneEventArgs e) {
// Subscribe to the events
rightStandardSearchGrid = e.Control as GridDataBoundGrid;
if (rightStandardSearchGrid != null) {
rightStandardSearchGrid.CurrentCellActivating += new GridCurrentCellActivatingEventHandler(dgrSearchResult_CurrentCellActivating);
rightStandardSearchGrid.CellDoubleClick += new GridCellClickEventHandler(dgrSearchResult_CellDoubleClick);
rightStandardSearchGrid.ResizingColumns += new GridResizingColumnsEventHandler(dgrSearchResult_ResizingColumns);
rightStandardSearchGrid.KeyDown += new KeyEventHandler(dgrSearchResult_KeyDown);
rightStandardSearchGrid.MouseUp += new MouseEventHandler(dgrSearchResult_MouseUp);
rightStandardSearchGrid.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(dgrSearchResult_PrepareViewStyleInfo);
}
}
private void gridRecordNavigationControl1_PaneClosing(object sender, Syncfusion.Windows.Forms.SplitterPaneEventArgs e) {
// Unsubscribe to the events
if (rightStandardSearchGrid != null) {
rightStandardSearchGrid.CurrentCellActivating -= new GridCurrentCellActivatingEventHandler(dgrSearchResult_CurrentCellActivating);
rightStandardSearchGrid.CellDoubleClick -= new GridCellClickEventHandler(dgrSearchResult_CellDoubleClick);
rightStandardSearchGrid.ResizingColumns -= new GridResizingColumnsEventHandler(dgrSearchResult_ResizingColumns);
rightStandardSearchGrid.KeyDown -= new KeyEventHandler(dgrSearchResult_KeyDown);
rightStandardSearchGrid.MouseUp -= new MouseEventHandler(dgrSearchResult_MouseUp);
rightStandardSearchGrid.PrepareViewStyleInfo -= new GridPrepareViewStyleInfoEventHandler(dgrSearchResult_PrepareViewStyleInfo);
}
}
4. Maybe the problem is rightStandardSearchGrid, dgrSearchResult have different types?
Actually, the above events run OK. However, I need to solve the others:
- If I move splitter bar toward right-hand and out of the GDBG, the original grid will be kept, events run OK.
- If I move splitter bar toward left-hand and out of the GDBG, the new grid will keep, events of the original grid not kept. How to fix it? How to display the orginal GDBG instead of new grid in this case.
- At the first time, I cannot click on rightStandardSearchGrid to select column, row. However, if I click on dgrSearchResult to select colum, row; then re-click rightStandardSearchGrid, it runs OK.
Please help!
Thanks a lot.
AD
Administrator
Syncfusion Team
January 5, 2005 07:28 AM UTC
First, in addition to subscribing to the events in PaneCreated, you also have to explicitly subscribe to the events for the initially created grid (maybe in the designer generated code or in Form.Load). In the code you pasted, I did not notice any code that did this.
Now, since you are using a derived grid, there is some additonal work you need to do. When the splitter wants a new grid, it calls the grid.CreateNewControl method. So, unless you override this virtual method, any new grid created when a pane is created will be a GridDataBoundGrid, and not your derived grid. So, any functionality you are implementing in the derived grid will not be seen in the new panes. So, try overriding CreateNewControl. Here is the code from the GridDataBoundGrid implementation. You would have create and return an instance of your derived grid.
public override Control CreateNewControl(Control parent, int row, int column)
{
GridDataBoundGrid grid1 = new GridDataBoundGrid(DataBoundGridModel);
WireNewControl(grid1);
return grid1;
}
DB
David Bosak
January 5, 2005 08:51 AM UTC
Hi Clay,
I am trying to solve this problem as your solution.
However, I have a question:
How to detain users in moving the splitterbar toward the left-hand when left-pane''s width is less than or equal 25 (leftPane.Width <= 25)?
I.e. Users cannot move the splitterbar toward the left if leftpane''s width <= 25.
Thanks!
AD
Administrator
Syncfusion Team
January 5, 2005 10:00 AM UTC
You can impose a minimum size by handling the splitter changed event.
private void gridRecordNavigationControl1_HSplitPosChanged(object sender, System.EventArgs e)
{
if(this.gridRecordNavigationControl1.HSplitPos < 25)
this.gridRecordNavigationControl1.HSplitPos = 25;
}
DB
David Bosak
January 6, 2005 03:01 AM UTC
How to not allow user to drag the splitter out of the grid?
AD
Administrator
Syncfusion Team
January 6, 2005 07:10 AM UTC
One way is to derive the recnavcontrol and override OnMoveSplitter, not calling the base class to ignore moves you do not allow.
public class MyGridRecordNavigationControl : GridRecordNavigationControl
{
public override void OnMoveSplitter(object sender, int x, int y)
{
Point pt = this.PointToClient(Control.MousePosition);
if(pt.X < 50 || pt.X > this.Size.Width - 50)
{
Console.WriteLine("Ignoring a splitter move.");
return;
}
base.OnMoveSplitter (sender, x, y);
}
}
DB
David Bosak
January 7, 2005 03:27 AM UTC
Thank a lot, it runs OK.