Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 24th, 2007, 01:20 PM
Authorized User
 
Join Date: Apr 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default Enforcing uppercase in a cell in a DataGridView

I'm having a problem determining where I can actually set a property to enforce the values typed into a cell in a grid to uppercase. I tried to enforce the uppercase in sql when the value was inserted but that failed.

Is there a way to use the cellvalidating event?

i.e. something like this (however this doesn't work)

private void dgFacenames_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
  {
    Convert.ToString((e.CellStyle.Format.ToUpper["facenameDataGridViewTextBoxColumn"]));
  }

Thanks in advance

 
Old April 24th, 2007, 01:43 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Try this instead: When you go to populate the GridView with data from sql, instead of doing:

SELECT [column] from table

try:
SELECT Upper([column]) as column from table

hth

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old April 24th, 2007, 02:33 PM
Authorized User
 
Join Date: Apr 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I would actually like to save it to the table in uppercase

I've found this as a solution but the [RowIndex] and [CellIndex] are not available in the event. Not sure how to make that work.

        private void dgFacenames_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {

         this.dgFacenames.Rows[RowIndex].Cells[CellIndex].Value = this.dgFacenames.Rows[RowIndex].Cells[CellIndex].Value.ToString().ToUpper();

        }






Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing a cell in a DataGridView Martin Woodhouse C# 2008 aka C# 3.0 12 October 3rd, 2008 08:42 AM
Merge Cell in Datagridview of visual basic 2005 Nambot VB.NET 2002/2003 Basics 1 November 12th, 2007 09:02 AM
datagridview cell validation kscase Pro Visual Basic 2005 1 July 12th, 2007 07:21 AM
DataGridView: Cell BackColor kesar VB How-To 0 January 8th, 2007 08:19 AM
uppercase and lowercase minhpx SQL Server 2000 1 January 25th, 2005 12:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.