Is there a way to put a limit on the text size of a datagrid column?
Thanks,
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks. 6 6468
Hi,
Here is a column style that i wrote that allows you set set max
length and character casing. Use it instead of a datagridtextbox column in
your datagrid tablestyle.
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.ComponentModel
<DataSysDescription("This column style adds Max length and Character Casing
to the datagrid textbox column")> _
Public Class ExtendedTextBoxColumn
Inherits DataGridTextBoxColumn
Dim mccText As CharacterCasing = CharacterCasing.Normal
Dim mintMaxLength As Integer = 0
<DataSysDescription("Upper, Lower, or Normal")> _
Public Property TextCharacterCasing() As CharacterCasing
Get
Return mccText
End Get
Set(ByVal Value As CharacterCasing)
mccText = Value
End Set
End Property
<DataSysDescription("Max Length of Text. Use 0 to retrieve full text")> _
Public Property MaxLength() As Integer
Get
Return mintMaxLength
End Get
Set(ByVal Value As Integer)
mintMaxLength = Value
End Set
End Property
Protected Overloads Overrides Sub Edit(ByVal source As
System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal bounds
As System.Drawing.Rectangle, ByVal [readOnly] As Boolean, ByVal instantText
As String, ByVal cellIsVisible As Boolean)
MyBase.Edit(source, rowNum, bounds, [readOnly], instantText, cellIsVisible)
MyBase.TextBox.CharacterCasing = mccText
If mintMaxLength > 0 Then MyBase.TextBox.MaxLength = mintMaxLength
End Sub
Protected Overrides Function GetColumnValueAtRow(ByVal source As
System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer) As Object
Dim obj As String
Dim strReturn As String
obj = MyBase.GetColumnValueAtRow(source, rowNum).ToString
Select Case mccText
Case CharacterCasing.Lower
strReturn = obj.ToLower
Case CharacterCasing.Upper
strReturn = obj.ToUpper
Case CharacterCasing.Normal
strReturn = obj
End Select
If mintMaxLength > 0 And strReturn.Length > mintMaxLength Then
strReturn = strReturn.Substring(0, mintMaxLength)
End If
Return strReturn
End Function
End Class
Ken
------------------------
"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:8l*****************@newssvr16.news.prodigy.co m...
Is there a way to put a limit on the text size of a datagrid column?
Thanks,
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Hi,
Here is a column style that i wrote that allows you set set max
length and character casing. Use it instead of a datagridtextbox column in
your datagrid tablestyle.
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.ComponentModel
<DataSysDescription("This column style adds Max length and Character Casing
to the datagrid textbox column")> _
Public Class ExtendedTextBoxColumn
Inherits DataGridTextBoxColumn
Dim mccText As CharacterCasing = CharacterCasing.Normal
Dim mintMaxLength As Integer = 0
<DataSysDescription("Upper, Lower, or Normal")> _
Public Property TextCharacterCasing() As CharacterCasing
Get
Return mccText
End Get
Set(ByVal Value As CharacterCasing)
mccText = Value
End Set
End Property
<DataSysDescription("Max Length of Text. Use 0 to retrieve full text")> _
Public Property MaxLength() As Integer
Get
Return mintMaxLength
End Get
Set(ByVal Value As Integer)
mintMaxLength = Value
End Set
End Property
Protected Overloads Overrides Sub Edit(ByVal source As
System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal bounds
As System.Drawing.Rectangle, ByVal [readOnly] As Boolean, ByVal instantText
As String, ByVal cellIsVisible As Boolean)
MyBase.Edit(source, rowNum, bounds, [readOnly], instantText, cellIsVisible)
MyBase.TextBox.CharacterCasing = mccText
If mintMaxLength > 0 Then MyBase.TextBox.MaxLength = mintMaxLength
End Sub
Protected Overrides Function GetColumnValueAtRow(ByVal source As
System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer) As Object
Dim obj As String
Dim strReturn As String
obj = MyBase.GetColumnValueAtRow(source, rowNum).ToString
Select Case mccText
Case CharacterCasing.Lower
strReturn = obj.ToLower
Case CharacterCasing.Upper
strReturn = obj.ToUpper
Case CharacterCasing.Normal
strReturn = obj
End Select
If mintMaxLength > 0 And strReturn.Length > mintMaxLength Then
strReturn = strReturn.Substring(0, mintMaxLength)
End If
Return strReturn
End Function
End Class
Ken
------------------------
"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:8l*****************@newssvr16.news.prodigy.co m...
Is there a way to put a limit on the text size of a datagrid column?
Thanks,
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
That works perfectly, Ken. Thank you very much.
Ken Tucker [MVP] wrote: Hi,
Here is a column style that i wrote that allows you set set max length and character casing. Use it instead of a datagridtextbox column in your datagrid tablestyle.
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.ComponentModel
<DataSysDescription("This column style adds Max length and Character Casing to the datagrid textbox column")> _
Public Class ExtendedTextBoxColumn
Inherits DataGridTextBoxColumn
Dim mccText As CharacterCasing = CharacterCasing.Normal
Dim mintMaxLength As Integer = 0
<DataSysDescription("Upper, Lower, or Normal")> _
Public Property TextCharacterCasing() As CharacterCasing
Get
Return mccText
End Get
Set(ByVal Value As CharacterCasing)
mccText = Value
End Set
End Property
<DataSysDescription("Max Length of Text. Use 0 to retrieve full text")> _
Public Property MaxLength() As Integer
Get
Return mintMaxLength
End Get
Set(ByVal Value As Integer)
mintMaxLength = Value
End Set
End Property
Protected Overloads Overrides Sub Edit(ByVal source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal bounds As System.Drawing.Rectangle, ByVal [readOnly] As Boolean, ByVal instantText As String, ByVal cellIsVisible As Boolean)
MyBase.Edit(source, rowNum, bounds, [readOnly], instantText, cellIsVisible)
MyBase.TextBox.CharacterCasing = mccText
If mintMaxLength > 0 Then MyBase.TextBox.MaxLength = mintMaxLength
End Sub Protected Overrides Function GetColumnValueAtRow(ByVal source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer) As Object
Dim obj As String
Dim strReturn As String
obj = MyBase.GetColumnValueAtRow(source, rowNum).ToString
Select Case mccText
Case CharacterCasing.Lower
strReturn = obj.ToLower
Case CharacterCasing.Upper
strReturn = obj.ToUpper
Case CharacterCasing.Normal
strReturn = obj
End Select
If mintMaxLength > 0 And strReturn.Length > mintMaxLength Then
strReturn = strReturn.Substring(0, mintMaxLength)
End If
Return strReturn
End Function End Class Ken
------------------------
"Aaron Smith" <th**********@smithcentral.net> wrote in message news:8l*****************@newssvr16.news.prodigy.co m... Is there a way to put a limit on the text size of a datagrid column?
Thanks, Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
That works perfectly, Ken. Thank you very much.
Ken Tucker [MVP] wrote: Hi,
Here is a column style that i wrote that allows you set set max length and character casing. Use it instead of a datagridtextbox column in your datagrid tablestyle.
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.ComponentModel
<DataSysDescription("This column style adds Max length and Character Casing to the datagrid textbox column")> _
Public Class ExtendedTextBoxColumn
Inherits DataGridTextBoxColumn
Dim mccText As CharacterCasing = CharacterCasing.Normal
Dim mintMaxLength As Integer = 0
<DataSysDescription("Upper, Lower, or Normal")> _
Public Property TextCharacterCasing() As CharacterCasing
Get
Return mccText
End Get
Set(ByVal Value As CharacterCasing)
mccText = Value
End Set
End Property
<DataSysDescription("Max Length of Text. Use 0 to retrieve full text")> _
Public Property MaxLength() As Integer
Get
Return mintMaxLength
End Get
Set(ByVal Value As Integer)
mintMaxLength = Value
End Set
End Property
Protected Overloads Overrides Sub Edit(ByVal source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal bounds As System.Drawing.Rectangle, ByVal [readOnly] As Boolean, ByVal instantText As String, ByVal cellIsVisible As Boolean)
MyBase.Edit(source, rowNum, bounds, [readOnly], instantText, cellIsVisible)
MyBase.TextBox.CharacterCasing = mccText
If mintMaxLength > 0 Then MyBase.TextBox.MaxLength = mintMaxLength
End Sub Protected Overrides Function GetColumnValueAtRow(ByVal source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer) As Object
Dim obj As String
Dim strReturn As String
obj = MyBase.GetColumnValueAtRow(source, rowNum).ToString
Select Case mccText
Case CharacterCasing.Lower
strReturn = obj.ToLower
Case CharacterCasing.Upper
strReturn = obj.ToUpper
Case CharacterCasing.Normal
strReturn = obj
End Select
If mintMaxLength > 0 And strReturn.Length > mintMaxLength Then
strReturn = strReturn.Substring(0, mintMaxLength)
End If
Return strReturn
End Function End Class Ken
------------------------
"Aaron Smith" <th**********@smithcentral.net> wrote in message news:8l*****************@newssvr16.news.prodigy.co m... Is there a way to put a limit on the text size of a datagrid column?
Thanks, Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Simply set DataGridTextBoxColumn.TextBox.MaxLength property in code
Simply set DataGridTextBoxColumn.TextBox.MaxLength property in code This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Shravan Kumar |
last post by:
Hi,
I am using my code to set column widths of datagrid
columns dynamically, but when I am setting the column
widths to zero, the header text of the column whose width
is made to zero is...
|
by: Frnak McKenney |
last post by:
One of the reasons given for the Allied victory in WWI is that the
Nazi armament industry invested so much effort in creating new
weapons (e.g. the jet plane) it wasn't able to develop any of them...
|
by: Ben |
last post by:
Hi, I'm wondering how can i change the datagrid header text at runtime so
that it keeps the sorting enabled?
I can do;
e.Item.Cells.Text = "foo";
But then foo is the text of the table cell...
|
by: martin |
last post by:
Hi,
I am iterating through the dataitems in a datagrid and producing and xml
document,
If a particular cell in the datagrid has a textbox control or a datagrid
control in it then I have no...
|
by: JenHu |
last post by:
hi,
I have a datagrid in my asp.net application, I am using vb.net
language.
I want to have my last column as a link column, link to text file.
The link path is "c:\Temp\" & F_File_Name, which...
|
by: Joe |
last post by:
I have an aspx page (referred to here as page_1) with a datagrid whose first
column contains hyperlinks. When a user clicks one of these hyperlinks, he
will navigate to another aspx page (referred...
|
by: Aaron Smith |
last post by:
Is there a way to put a limit on the text size of a datagrid column?
Thanks,
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
|
by: Melson |
last post by:
Hi
I've a problem. Can anyone help. I would like to use datagrid for data
entry. How can I set the number of rows in the datagrid. And use the
datagrid to update the ms sql table.
regards...
|
by: JamesOo |
last post by:
I have the code below, but I need to make it searchable in query table,
below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only,...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
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...
|
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...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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,...
| |