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.

Exception displaying in grid cell

Thread ID:

Created:

Updated:

Platform:

Replies:

12476 Mar 31,2004 08:47 AM Apr 2,2004 05:49 AM Windows Forms 12
loading
Tags: GridControl
Josh King
Asked On March 31, 2004 08:47 AM

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

Administrator [Syncfusion]
Replied On March 31, 2004 09:34 AM

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.

Josh King
Replied On March 31, 2004 12:39 PM

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!

Josh King
Replied On March 31, 2004 01:37 PM

Sorry, I mean to say "turn red"

Administrator [Syncfusion]
Replied On March 31, 2004 02:59 PM

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)

Josh King
Replied On April 1, 2004 12:05 PM

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

Administrator [Syncfusion]
Replied On April 1, 2004 12:21 PM

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

Josh King
Replied On April 1, 2004 12:44 PM

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.

Administrator [Syncfusion]
Replied On April 1, 2004 12:55 PM

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?

Josh King
Replied On April 1, 2004 01:01 PM

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.

Josh King
Replied On April 1, 2004 02:46 PM

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.

Administrator [Syncfusion]
Replied On April 1, 2004 05:40 PM

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

Josh King
Replied On April 2, 2004 05:49 AM

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

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.

;