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

Upper case in drop down list

What is the best way to force uppercase characters in a GridBoundCell of type DropDownList? I know that the following command only works for an original textbox: this.gbc.StyleInfo.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; The typed characters may or may not be items in the drop down list if it matters. Thank you, Steve

3 Replies

AD Administrator Syncfusion Team September 9, 2004 11:11 AM

You might try handling CurrentCellValidingString and force things to be upper there.
private void gridDataBoundGrid1_CurrentCellValidateString(object sender, GridCurrentCellValidateStringEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	int col = this.gridDataBoundGrid1.Binder.NameToColIndex("Col1");
	if(cc.ColIndex == col)
	{
		GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;
		int selstart = cr.TextBox.SelectionStart;
		int sellen = cr.TextBox.SelectionLength;
		cr.Control.Text = e.Text.ToUpper();
		cr.TextBox.SelectionStart = selstart;
		cr.TextBox.SelectionLength = sellen;
	}
}


TS Todd Swygert September 14, 2004 11:55 AM

This is not working for me. The very first character will be lowercase if the first character is not in the drop down list. If I hit the backspace key to delete the lowercase letter and then type the same lowercase letter again it will change the letter to uppercase. Not that it matters but the cr.Control.Text = e.Text.ToUpper(); line will fire the validation event from within the validation event. If I remove the handler and add the handler from within the event, I still can''t get it to work. Any help is much appreciated.


AD Administrator Syncfusion Team September 14, 2004 12:21 PM

I think if you set this.gridDataBoundGrid1.ActivateCurrentCellBehavior = GridCellActivateAction.SetCurrent; you can avoid this problem. If you do not want to use this SetCurrent property, then you can try handling grid.KeyDown.
private void gridDataBoundGrid1_KeyDown(object sender, KeyEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	if(!cc.IsEditing)
		cc.BeginEdit();
}

Loader.
Live Chat Icon For mobile
Up arrow icon