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.

Retrieving the display value from a ComboBox in a GridDataBoundGrid.

Thread ID:

Created:

Updated:

Platform:

Replies:

11354 Mar 3,2004 08:00 AM Mar 4,2004 07:46 AM Windows Forms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 3, 2004 08:00 AM

I have a GridDataBoundGrid bound to a table within a DataSet. One of the columns is a ComboBox lookup thingy, and everything works just swell. Except one thing! In the grid_Resize(...) eventhandler I''m auto-resizing the columns according to the longest text in each cell, but when I try to retrieve the text that the ComboBox displays, I always get the ValueMember!! I''ve tried many things and amoong those the obvious grid[x,y].Text, grid[x,y].FormattedText etc. etc., but to no avail. As the cell''s DataSource, I''m using an ArrayList() containing elements of a class having the ValueMember and the DisplayMember properties of the type string. Did anybody encounter the same problem? Did you solve it? Regards, Eyvind

Administrator [Syncfusion]
Replied On March 3, 2004 08:30 AM

You should be able to get the DisplayMember using grid[row,col].FormattedText. This seems to work as expected in the sample below for me. Does this sample work for you? Check your mapping names as these will be case sensitive. forum11354_8653.zip

Administrator [Syncfusion]
Replied On March 4, 2004 04:39 AM

Well...that was a tricky one! Your example of course worked fine, and it took me some time to replicate the error. Here''s what I did to your attached project to bring out the error: Add a Windows.Forms.TabControl to form1. Create two tabs and put the GridDataBoundGrid on the second tab, not selected at startup. In form1_load add grid.BorderStyle = BorderStyle.Fixed3D and change the number of rows in the table to no more than 11 rows. Now create a handler for the grid_resize event and voila! The very first time - and only the first time - the grid_resize event fires, grid[x,y].FormattedText actually returns the value of grid[x,y].Text. Go figure! I''ve attahed my project. Regards, Eyvind GridError_9224.zip

Administrator [Syncfusion]
Replied On March 4, 2004 07:08 AM

In the sample you sent, exactly what steps do I take to see the problem? Do I size the form smaller so there are fewer than 12 rows? And at that time I should see the message box? Or, do I size it a couple of time so the rowcout is always less than 12? And then I see the messagebox? So, far I have not been able to see the messagebox using our 2.0 code base (but there have been someproblems fixed in this code base that might affect what you are seeing). What version of the grid are you using? In earlier version, there was a problem with teh combobox binding context not being set, and this wouold cause first time problems. But it sounds like you are having second time problems. I suspect it is a bindingcontext issue. When you have a grid on a tabpage, then the grid will use the tabpage''s binding context and not teh form''s binding context. Sometimes this cause things to get out of sync. Try this in this formload to see if it helps. this.gridDataBoundGrid1.BindingContext = this.BindingContext; this.gridDataBoundGrid1.Model.CellModels["ComboBox"].BindingContext = this.BindingContext; This should force everything to use the same bindingcontext (that of the form''s).

Administrator [Syncfusion]
Replied On March 4, 2004 07:46 AM

The problem occures the first time the second tab is clicked, as the code is. I am using version 1.6.1.0. However, your little hack with the BindingContext resolved the problem. This will do for now. Most likely the problem is no longer present in the newer versions. When does 2.0 ship? :-) Thanks for your time. Eyvind

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.

;