473,398 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Custom DataGridViewTextBoxColumn & DataGridViewTextBoxEditingControl

Hello, I am trying to makethat user will be unable to enter a "," in a cell

What I was thinking was to make a custom columntype, and indeed, I created it, I have to override OnKeyPress event.

So, I was doing the following:
Expand|Select|Wrap|Line Numbers
  1. public class MyCustomControl : System.Windows.Forms.DataGridViewTextBoxEditingControl
  2. {
  3. protected override void OnKeyPress(KeyPressEventArgs e)
  4. {
  5. if (e.KeyChar == ',')
  6. {
  7. base.OnKeyPress(e); //Ok
  8. }
  9. else
  10. {
  11. e.Handled = true; //Deny
  12. }
  13. }
  14. }
  15.  
  16. public class TextBoxWithoutComma : System.Windows.Forms.DataGridViewTextBoxColumn
  17. {
  18. //I dunno what to put here to use my current control
  19. }
  20.  
  21.  
Mar 29 '07 #1
1 5791
Hello, I am trying to makethat user will be unable to enter a "," in a cell

What I was thinking was to make a custom columntype, and indeed, I created it, I have to override OnKeyPress event.

So, I was doing the following:
Expand|Select|Wrap|Line Numbers
  1. public class MyCustomControl : System.Windows.Forms.DataGridViewTextBoxEditingControl
  2. {
  3. protected override void OnKeyPress(KeyPressEventArgs e)
  4. {
  5. if (e.KeyChar == ',')
  6. {
  7. base.OnKeyPress(e); //Ok
  8. }
  9. else
  10. {
  11. e.Handled = true; //Deny
  12. }
  13. }
  14. }
  15.  
  16. public class TextBoxWithoutComma : System.Windows.Forms.DataGridViewTextBoxColumn
  17. {
  18. //I dunno what to put here to use my current control
  19. }
  20.  
  21.  
Anyway... I am just trying now when I create the "num" column to use my current control... not working..

Expand|Select|Wrap|Line Numbers
  1. this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  2.             this.num});
  3. this.num.HeaderText = "Number";
  4.             this.num.Name = "num";
  5.             this.num.DataGridView.EditingControl += new  System.Windows.Forms.DataGridViewTextBoxEditingControl(myCustomControl.nCampoGrillaC); <- error
  6.  
Mar 29 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Tim Wallace | last post by:
I'm playing around, albeit quite seriously, with Visual C# 2005 Express Edition. I added a DataGridViewTextBoxColumn to a DataGridView. I want to only allow this column to contain left...
2
by: Wayne Gibson | last post by:
Hi, I'm using the DataGridViewTextBoxColumn and I'm trying to find a way to detect when the a key is pressed whilst it is being edited. But there doesn't appear to be any events for this.. So...
6
by: Suzanne | last post by:
Hi all, I really hope someone out there can help me as I've been tearing my hair out on this one for a good while and I'm getting really frustrated now! My problem is this - my custom...
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
1
by: John J. Hughes II | last post by:
I am trying to create a custom DataGridViewCell which is "NOT" derived from DataGridViewTextBoxColumn. The painting works fine but I am unable to get the control into edit mode. Do I need to...
0
by: Louis-Pierre Dauphinais | last post by:
Please help, easily reproduced: 1. Create a class inheriting from System.Windows.Forms.DataGridViewTextBoxColumn . 2. Add a simple property to that class (see below for the code I used). 3. Add...
2
by: Kevin | last post by:
I've created a custom class that inherits from the DataGridViewTextBoxColumn and DataGridViewTextBoxCell. The cell is databound to a text field that contains the path to a JPG image. The JPG image...
3
by: Claes Wedin | last post by:
I'm doing a Component class that inherits from DataGridView. One thing that it does is to add a default column in the grid. I put the code for this in the class and when I drag the control to my...
0
by: =?Utf-8?B?cG1haw==?= | last post by:
I try to implement a AutoComplete function to the datagridviewtextboxcolumn to a Datagridview control with several others datagridviewtextboxcolumns. This function is meant to apply to the column,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.