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

Databound grid access

Thread ID:

Created:

Updated:

Platform:

Replies:

12367 Mar 27,2004 04:34 AM Apr 3,2004 03:51 AM Windows Forms 5
loading
Tags: GridControl
Rajiv
Asked On March 27, 2004 04:34 AM

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 12:09 PM

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?

Rajiv
Replied On March 29, 2004 12:00 AM

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 01:49 AM

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.)

Rajiv
Replied On April 3, 2004 03:32 AM

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 03:51 AM

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);

CONFIRMATION

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.

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.

;