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.
What version are you using?
NetAdvantage 2003
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.
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?
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.
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)