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

Exception displaying in grid cell

I''m using a data bound AutoComplete ComboBox in the GridControl. Sometimes the ComboBox will display the ValueMember and not the DisplayMember and then when a user double clicks on the ComboBox the text changes to the Display Member. If the user double clicks again the cell turns red and the text in the cell is changed to read "Exception". What is this exception and how would I trap it? Also, do you have any idea why the combo box would show the ValueMember is only certain circumstances? I''ve attached the code that is building the grid. Thanks, Grid_7159.zip

12 Replies

AD Administrator Syncfusion Team March 31, 2004 02:34 PM UTC

Is -10 a value in the OriginalID column in ds.Tables["ComboRecordset"].DefaultView? If it is not, then you should not be setting it to be the value of the cell (since you are using DropDownStyle = AutoComplete, every cell value must be a value in the list unless the cellvalue is DBNull.Value). Another thing to check is try removing the ExclusiveChoiceList setting. That is replaced DropDownStyle setting when you set a DataSource instead of a ChoiceList.


JK Josh King March 31, 2004 05:39 PM UTC

That -10 is getting added to the table, so it is a valid value. But besides that, does anybody know what causes the cell to turn and read and have text read "Exception"? I would just like to know how to trap it. Thanks!


JK Josh King March 31, 2004 06:37 PM UTC

Sorry, I mean to say "turn red"


AD Administrator Syncfusion Team March 31, 2004 07:59 PM UTC

This happens when an exception is thrown as the grid is drawing the cell. If you set the debugger to break on exception, you should be able to get a callstack when the exception is being thrown. The actual exception is thrown in this routine: Essential Suite\Grid\Src\Base\Control\GridControlBase.cs(2789): virtual public void OnDrawItem(Graphics g, int rowIndex, int colIndex, Rectangle rectItem, GridStyleInfo style)


JK Josh King April 1, 2004 05:05 PM UTC

My Pictures_7992.zip Here is some screen shots of what I was talking about. In the first view it shows the ValueMember. After double clicking on the cell it displays the displaymember of what the cell should be showing. After leaving the cell it shows the red exception text. If you have any insight on what''s going on it would be helpful because we don''t really know what to do about this. Thanks, Josh


AD Administrator Syncfusion Team April 1, 2004 05:21 PM UTC

How does the value member get into the cell in the first picture? Normally, the value member is never displayed (you only see the DisplayMember). The reason it might show a valuemember value is if that valuemember value is not in the current DataSource for the column''s combobox. At the point you see 14 in the cell, is 14 in the valuemember column of the combobox''s DataSource? If you are somehow trying to dynamically set the DataSource for the combobox column(it is not set once in FormLoad, for example), then this can be tricky an dlead to the kind of problems you see. There is a KB showing one way to do this. http://www.syncfusion.com/Support/article.aspx?id=567


JK Josh King April 1, 2004 05:44 PM UTC

That''s what my question is. It''s not clear to me why the ValueMember is displaying in the first picture. The ValueMember is 14 and the DisplayMember is Ancillary Provider (in the second picture). So I would assume it would display the DisplayMember like the other cells are doing, but it''s not.


AD Administrator Syncfusion Team April 1, 2004 05:55 PM UTC

Are you dynamically setting the DataSource of the column? If you can post a sample project showing the problem, we can try to debug it here?


JK Josh King April 1, 2004 06:01 PM UTC

I''ll try to get something together and send it. The DataSource is set on the creation of each cell and it''s not changed after that.


JK Josh King April 1, 2004 07:46 PM UTC

TestTranslation_5211.zip Here is the project. As you can see the first row of the grid is displaying the ValueMember in the drop down. You can call email me directly with any questions.


AD Administrator Syncfusion Team April 1, 2004 10:40 PM UTC

The InsertAt you are using to add the -10 item at the start of the list is breaking things. In the sample, if I move it down to where you create the table, things work OK for me (using 2030 code). DataTable dt = new DataTable("ComboRecordset"); dt.Columns.Add(new DataColumn("OriginalID", typeof(int))); dt.Columns.Add(new DataColumn("Name")); DataRow dr = dt.NewRow(); dr["OriginalID"] = -10; dr["Name"] = ""; dt.Rows.Add(dr); //... continue adding the rows...


JK Josh King April 2, 2004 10:49 AM UTC

Ok, I don''t why it would break it but if that fixes it, that''s fine for now. Thanks for your help.

Loader.
Live Chat Icon For mobile
Up arrow icon