We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How to get DataType for each ggc column to validate user input

Hello,

Please advise me how to get DataType if we populate ggc from dataset, in order that we can customize text alignment, validate user input in each column of each table?
P.S. There are visible columns removed.

Thanks and Best Regards,
Harry


3 Replies

VK Vinoth Kumar K Syncfusion Team January 30, 2008 10:40 PM UTC

Hi Harry,

Thanks for using Syncfusion Products.

You can get the DataType of each column in GridGrouping Control by using the following code.Please refer to the code given below:


private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i <= 4; i++)
{
GridColumnDescriptor column = this.gridGroupingControl1.TableDescriptor.Columns[i];
Console.WriteLine(column.FieldDescriptor.GetPropertyType());
}
}


Please let me know if you have any questions.

Regards,
Vinoth




HA harisan February 1, 2008 12:56 PM UTC

Hi Vinoth,

Thanks for your assit, this code works but the problem is that: it got wrong column index reference due if there is any visible column(s) removed.

However I got advise from Haneef to implement this code:
Private Sub gridGroupingControl1_TableControlCellClick(ByVal sender As Object, ByVal e As GridTableControlCellClickEventArgs)
Dim cm As CurrencyManager = e.TableControl.Table.GetCurrencyManager()
Dim dv As System.Data.DataView = cm.List

If Not dv Is Nothing Then
Dim col As GridColumnDescriptor = e.TableControl.Table.GetColumnDescriptorAt(e.Inner.RowIndex,e.Inner.ColIndex)
If Not col Is Nothing Then
Console.WriteLine(col.MappingName)
Console.WriteLine( dv.Table.Columns.Contains(col.MappingName) )
End If
End If
End Sub

The problem is I got InvalidCastException error on this line:
Dim dv As System.Data.DataView = cm.List

Please advise me how to fix it?

Thanks,
Harry



VK Vinoth Kumar K Syncfusion Team February 1, 2008 06:34 PM UTC

Hi Harry,

Please follow the below forum thread for more details.
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=71382

Best regards,
Vinoth


Loader.
Live Chat Icon For mobile
Up arrow icon