Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

C# datagridview row enforcing casing

Posted on 2011-03-07
2
Medium Priority
?
689 Views
Last Modified: 2012-05-11
Based on somebody's answer to a previous question, I enforce character casing in datagridview cells as seen in the attached code.

Now I need to selectively enforce casing.  That is, for colDesc1 I don't want to enforce casing whereas for colItemNo I do want to enforce casing.

I can't find a way to do this.  I tried e.Control.Name, but it is an empty string.  I noticed e.Control.Tag, but cannot assign a tag in the datagridview interface.  I tried e.Control.Location, but that didn't work.

Any suggestions?
private void dgvMain_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            if (e.Control is TextBox)
                ((TextBox)e.Control).CharacterCasing = CharacterCasing.Upper;
        }

Open in new window

0
Comment
Question by:g_johnson
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 35063283
What about expanding the code to this:
private void dgvMain_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
    DataGridView grid = sender as DataGridView;

    if (grid.SelectedColumns[0].Name == "colItemNo" && e.Control is TextBox)
        ((TextBox)e.Control).CharacterCasing = CharacterCasing.Upper;
}

Open in new window

0
 
LVL 4

Author Comment

by:g_johnson
ID: 35071729
I was not able to use SelectedColumns[0] (apparently it's not set), but I was able to use ColumnIndex to get where I was going.

thanks for the help
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question