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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Character Casing

Thread ID:

Created:

Updated:

Platform:

Replies:

1162 Sep 29,2002 03:54 AM UTC May 29,2003 04:04 PM UTC WinForms 3
loading
Tags: FAQ
kawoshSoftGroup
Asked On September 29, 2002 03:54 AM UTC

How Can I Write In Cell Of DataGride With UpperCase?

FruitBatInShades
Replied On October 3, 2002 07:41 AM UTC

Convert the data your adding to uppercase either use:- string.toUpper or ucase(string)

Administrator [Syncfusion]
Replied On October 3, 2002 09:54 AM UTC

The problem is getting at the control thatis handling the keystrokes. When you type in a grid cell, it is an embedded TextBox that gets the keystrokes and not the datagrid. One way you can handle this is to look through all the controls that are parented by the datagrid, and hook a KeyPress eventhandler for each parented textbox. You could do this at the end of Form_Load after the DataGrid has been set up. Here is code that does this.
foreach(Control c in this.dataGrid1.Controls)
{
	TextBox tb = c as TextBox;
	if(tb != null)
	{
		tb.KeyPress += new KeyPressEventHandler(CellKeyPress);
	}
}
Then in your CellKeyPress method, check to see if you are on the cell you want to be uppercase, and if so, handle things. Here is a try at this.
private void CellKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
	if(this.dataGrid1.CurrentRowIndex == 1 && this.dataGrid1.CurrentCell.ColumnNumber == 1)
	{
		TextBox tb = sender as TextBox;
		if(tb != null && char.IsLetter(e.KeyChar) && !char.IsUpper(e.KeyChar))
		{
			SendKeys.Send(char.ToUpper(e.KeyChar).ToString());
			e.Handled = true;
		}
	}
}

boshra
Replied On May 29, 2003 04:04 PM UTC

> How Can I Write In Cell Of DataGride With UpperCase?

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;