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?
ADAdministrator Syncfusion Team 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.
ADAdministrator Syncfusion Team 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.
ADAdministrator Syncfusion Team 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).
ADAdministrator Syncfusion Team 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 188.8.131.52.
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.