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

GridListControl

How do I get the results of a GridListControl selection to be automatically accepted without the user having to hit enter or select another cell? Generally, I would prefer this behavior and in this specific case I am using the GridList Control in a dropdowngrid and I want to be able ensure that the last selection is accepted should the user close the dropdowngrid without hitting enter etc. Also, FYI it appears that OnCurrentCellCloseDropDown is not documented along with the other CurrentCell dropdown events.

4 Replies

AD Administrator Syncfusion Team January 15, 2003 04:36 PM UTC

Here is some code that you can add to the CellControlsGrid sample to get this behavior.
private void CellControlsForm_Load(object sender, System.EventArgs e)
{
	GridDropDownGridListControlCellRenderer cr = 
		(GridDropDownGridListControlCellRenderer) this.gridControl1.CellRenderers["GridListControl"];
	cr.ListControlPart.SelectedValueChanged += new EventHandler(SelectionChanged);
}

private void SelectionChanged(object sender, EventArgs e)
{
	GridDropDownGridListControlCellRenderer cr = 
		(GridDropDownGridListControlCellRenderer) this.gridControl1.CellRenderers["GridListControl"];
	int i = cr.ListControlPart.SelectedIndex;
	if(i > -1)
	{
		cr.EditPart.Text = cr.ListControlPart.Grid[i+1, 2].Text;
		this.gridControl1.CurrentCell.ConfirmChanges(false);
	}
}


JN Joseph Nash January 16, 2003 01:22 AM UTC

Thanks for the response but not much sucess with it. I tried the code changes you suggested in the sample (CellControlsGrid) and in my code with different but not correct actions in either case. The code as suggested wouldn't compile beacuse there are no overloads for ConfirmChanges that take any parameters, neither the documentation nor the tool tips shows any alternatives. So I removed the false parameter and it compiled. In the sample the popup drops but as soon as the mouse passes over it closes without an opportunity to click on anything. After insetring a write to the console Console.WriteLine(i.ToString()); if(i > -1) ... -1 is written when the popup drops and the index of the item passed over first is then displayed in output. (by entering the popup from the side I can pass over different items). In my code which is in a custom dropdowngrid, I couldn't hook it in form load so, I did that in OnCurrentCellShowedDropDown (OnCurrentCellShowingDropDown was too early) and later remove it in OnCurrentCellCloseDropDown. I get an event when the control drops and as each item is passed over but the selectedIndex is always -1. I also tried hooking cr.DropDownContainer.CloseUp the event fired but the selectedIndex again is -1. Any thoughts?


AD Administrator Syncfusion Team January 16, 2003 10:22 AM UTC

I am using version 1.5.1.4. In that version, ConfirmChanges has been overloaded to accept a bool parameter that indicates whether or not any dropdown should be closed. This parameter is exactly what is needed in your case to prevent the dropdown from closing prematurely. When the 1.5.1.4 version, the CellControls sample does compile and run and change the valsue displayed in the edit box as you move your mouse over the dropped list. You can get 1.5.1.4 as a private patch from your support home page on our web site. (Click on the Download Latest Service pack link). You might try this code with this 1.5.1.4 release. We will have a public patch available based on this source code in a week or so.


JN Joseph Nash January 16, 2003 03:35 PM UTC

Thnaks that did it. My code was looking at the cellrenderers for the top level grid, changing it to use the currentcell in the dropdowngrid fixed my problem.

Loader.
Up arrow icon