Print Page | Close Window

Update DataGridView cell values based on text input into other grid cells

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=413
Printed Date: 11-Jun-2026 at 9:05pm


Topic: Update DataGridView cell values based on text input into other grid cells
Posted By: Miszou
Subject: Update DataGridView cell values based on text input into other grid cells
Date Posted: 06-Sep-2007 at 9:09am
I have a datagridview with the following columns on it: FirstName, LastName, UserName.
 
When the user adds a new row to the datagrid, to create a new user, I automatically begin editing in the FirstName cell. However, I want the UserName to be updated as the user types into the FirstName and LastName fields in order to provide a default user name. (This only occurs for new users - existing users do not automatically update the UserName)
 
The default UserName should be the FirstName + the first character of LastName.
 
Is there any way to get the UserName cell to automatically update as the user is typing in the FirstName or LastName fields? This is a databound datagridview, with appropriate DevForce Binding Source and DGVBM.
 
I have attached to the TextChanged event of the edit control that appears for in-cell editing, and I can read cell value as it changes, but whenever I try to set the value of the UserName field (either through the grid or through the binding source), the editing cell and the UserName cell get blanked out, I recieve extra TextChanged events that and the edit control is blanked out as well.
 
I'm sure I'm pretty close, but there's just some piece of the puzzle that I'm missing!
 
 
 



Print Page | Close Window