Hi
I am setting a DataTable as DataSource of UltraWinGrid.
I am using same grid for Edit and Insert functions. When I add new row to the grid, I need to restrict length of data entered in each column according to the SQL datasource.
If I use Grid.DisplayLayout.Band.Column.FieldLen property it gives error that "Can't set when bound to a database"
How can I limit Text entered in the grid?
Thanks
Shivangi
You need to look at the column properties of the grid such as Min Length,Max Length, Min Value, Max Value.
I have multiple columns with different data type and length requirements.
When I tried Grid.DisplayLayout.Band(0).Column("ABC").MaxValue = 123 for a column having VarChar as data type nothing happened.
I could not find MaxLength property of columns.
The max value property is for numeric type columns. If you want to restirict the string length try this instead.
Grid.DisplayLayout.Bands(0).Columns("ABC").MaxLength = 123
I do not see MaxLength as property of the column. Is this addition to new versions as I am using older version.
Is there any other way of achieving this if I do not see MaxLength property?
What version are you using?
NetAdvantage 2003
Hi Mike,
I could not find EditorResolved Property may be because of my version.
But this is how I could resolve the issue
Grid.ActiveCell.Value = Grid.ActiveCell.Text.Substring(0, 49)
Hi Shivangi,
Try using:
grid.ActiveCell.EditorResolved.Text
That should give you a Text property that you read as well as set for text columns.
Another way to do it would be to use grid.Controls[0] and cast it to a TextBox control and use the Text property of that. Again, this will only work for text columns.
I understand the version i have does not have MaxLength property available.
I could catch that entered Text is over Maximum limit in CellChange Event.
Now, I need to truncate the Text string I tried to change text by
Grid.ActiveRow.Cells("ABC").Text = Grid.ActiveRow.Cells("ABC").Text.Substring(0, 49)
But it gives error as Text is a readOnly property.
Could you please advice on how I could truncate text in activecell?
Wow that is pretty old. I have no documentation on that version of the grid, but I would imagine that the max length feature may have been added afterwards if you don't have that property available. But I don't know for sure so that is just an observation.