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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Databound grid access

Thread ID:





12367 Mar 27,2004 09:34 AM UTC Apr 3,2004 08:51 AM UTC WinForms 5
Tags: GridControl
Asked On March 27, 2004 09:34 AM UTC

Hi, I am using a databound grid. In grid i have some columns of type ComboBox and corresponding data column is of type bool. Now some time when i try to get the state of combo box using the data table it gives me error ''specfied cast not valid'' if((bool)m_AlarmDetailsTable.Rows[Index] [DisplayGuageColIndex]) strDisplayGuage = "1"; Please go through attached code for details. -Rajiv

Administrator [Syncfusion]
Replied On March 27, 2004 05:09 PM UTC

Is the value Nothing (or DBNull.Value)? If so, this will give you an invalid cast. It appears you are directly checking the values in the DataTable. Can you post a sample project showing the problem?

Replied On March 29, 2004 05:00 AM UTC

Please find attached code. I am checking on bool value which is set to false by default. This problem is not very regular. -Rajiv >Is the value Nothing (or DBNull.Value)? If so, this will give you an invalid cast. > >It appears you are directly checking the values in the DataTable. > >Can you post a sample project showing the problem? AlarmUI_9703.zip

Administrator [Syncfusion]
Replied On March 29, 2004 06:49 AM UTC

I cannot run your code because of missing references so I cannot debug into the problem to try to spot what is going on. Here is something to try. Instead of trying to set a default value with this code, gridAlarmDetails.Binder.InternalColumns[Index].StyleInfo.CellValue = false; try this code: gridAlarmDetails.Model.ColStyles[Index + 1].CellValue = false; The grid gets it default column values from the values in ColStyles. If this does not work, then try setting the DataColumn.DefaultValue for each of these columns in the DataTable. (Set these DefaultValues before you add any rows to the Datatable.)

Replied On April 3, 2004 08:32 AM UTC

Hi, Even after setting the default values it is giving same error. I did some analysus and founf out that ''Specified cast not valid'' error comes when we try to access some cell after draging some cell over it. Now my problem is how to disable drag and drop for essential grid. I have the following code but it does not disable the draging. // Disable Drag Drop gridAlarmDetails.Model.Options.AllowDragSelectedCols = false; gridAlarmDetails.Model.Options.AllowDragSelectedRows = false; gridAlarmDetails.Model.Options.DragDropDropTargetFlags = 0; gridAlarmDetails.Model.Options.DragSelectedCellsMouseButtonsMask = System.Windows.Forms.MouseButtons.None; In my grid i have some static field, checkboxes etc. Please refer to attached file for more details. Regards, Rajiv AlarmsManagerUI_5838.zip

Administrator [Syncfusion]
Replied On April 3, 2004 08:51 AM UTC

The code you show controls whether you can move rows/column by first selecting them, and then mousing down on the selected row/columns to move them to a new position. If you want to turn off ole drag and drop support in the grid, you use code like: this.gridControl1.ControllerOptions = GridControllerOptions.All & (~GridControllerOptions.OleDataSource);


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon