New Visual Studio 2010 WinForms C# project and imported existing form containing IG 2009 controls, which were updated to NetAdvantage 2011.
Our practice and existing code would always first our UltraCombo's datasource = null; before setting the datasource = datatable object returned from a SQL procedure call.
I was shocked to see that if the UltraCombo was already bound to a datatable, the calling of the same method to set a datasource is firing the RowSelected event of the combo when combo.datasource = null; is executed!
Needless to say, this is wreaking havoc in the project and we're looking for direction.
Is this a bug or something new in 2011??
Thanks!
Hi,
I tried this out and I am not seeing this behavior. If I have an UltraCombo with a selected row and I set the DataSource to null, RowSelected does not fire at that point. It does fire when I set the DataSource to something new, though - if the same value it previously had matches up to something on the new list.
This is correct behavior, since the actual Row object is different, even though the Value and text are the same.
I am attaching my sample project here so you can check it out. If I run the sample and click the button, the RowSelected event does not fire. This is correct, since there was no selected row to start with and changing the DataSource has no effect on that.
If I select a row and then click the button, the RowSelected event fires once. This is also correct since the original selected row was destroyed and a new row was created which happens to match the existing Value of the control (the Key field).
Hi Mike,
Thank you for the response and code. More specifically, I have 4 combo controls. I will refer to them as c1, c2, c3... Some event sets c1's datasource = datatable. The row selected event on all of the combos is set to load a datatable to the next combo in-line. This code has been in Production for several months, again as a Visual Studio 2008 project and NetAdvantage 9.
Workflow: User selects a value from c1 and a method is called from c1’s row selected event to set c2, c3 and c4’s datasource to null (to clear them) then c2’s datasource to a new datatable relevant to the value selected in C1. User then selects a value from c2 and c2’s row selected event calls a method to set c3 and c4’s datasource to null, then c3’s datasource is set to a new datatable, etc. The user can elect to have values selected in just c1 or all 4 combos. It depends on the amount of filtering they want to set for an eventual button click to return data to a grid.
So it appears that the row selected event does not automatically fire when the combo's datasource is set in version 9, but now does in v 2011? If this isn’t the case, I am willing to concede that I have no clue how to properly code this workflow. Again, what I have has been working perfectly in the Visual Studio 2008 project with 9.2 controls. I cannot get it to work the same in Visual Studio 2010 and 2011 controls. My latest iteration is leaving each combo with the previously selected value regardless of what value they select. It has been one of those weeks... :(
I noted that is was a non-working project. Because the project sits atop SQL I could not quickly assemble a working example for you, but I wanted you to see the methods and events involved that work as a Visual Studio 2008 \ IG 9.2 project, but fails when converted to a VS 2010 \ IG 2011 project.
There are detailed notes as comments in the Form1 code.
Oh, sorry... when you wrote "non-working", I thought you mean that the sample demonstrates the problem so it's non-working in the sense that it's not working correctly.
Anyway... I'm looking at the sample code, but I'm not really sure how this is supposed to help. I can see that your sample is getting a DataSet and setting the DataSource to null and then to a real DataSource. But I already knew that from your previous posts.
What I still don't know is what's wrong with it? What exactly is not working.
Your original post said that the RowSelected event was firing when you set the DataSource to null. But I tried to reproduce that and I posted my sample here and that is not happening for me.
Are you saying that this is still happening in your application? Did you try running the sample I posted here? If so, does it happen in the sample?
If your application is giving you different results than my sample, then we need to figure out why. It's most likely some property setting in your application that is different from my sample. But I can only make wild guesses about what this might be. You will need to look at your application and see what property settings you are applying to the Combo. Try commenting them out and see if you can narrow down which one it is.
If your sample and mine are behaving the same, then what exactly is the difference in behavior that you are getting between 9.1 and 11.1.
The same thing again, this time with an existing VS 2008 C# project after its IG 2009.1 controls were updated to the latest 2011.2. This time only two UltraCombo controls cmbA and cmbB.
Chain of events:
private void cmbA_RowSelected(object sender, RowSelectedEventArgs e) { ChangeFocus(); // simply sets focus to the status bar this.cmbA.Refresh(); if (cmbA.Value != null) { ShowHideDropDowns(); } }
private void ShowHideDropDowns() { switch (this.cmbA.Text.ToUpper()) { case "A": LoadDropDown("cmbSectorL2", "mySQLStoredProcedureA", null); this.cmbB.Visible = false; break; case "B": LoadDropDown("cmbB", "mySQLStoredProcedureB", null); this.cmbB.Visible = true; break; default: break; } }
private void LoadDropDown(string dropdownName, string spName, SqlParameter[] sqlparm) { DataSet ds = null; SqlParameter[] sqlParms = null; switch (dropdownName) { case "cmbA": if (this.cmbA.DataSource == null) { sqlParms = new SqlParameter[] { new SqlParameter("@Parm1", 2) }; ds = _mySQL.GetDataSet(_settings.myConnectionString, spName, "Data", sqlParms); this.cmbA.DataSource = ds; this.cmbA.ValueMember = "Value"; this.cmbA.DisplayMember = "Display"; } break; case "cmbB": sqlParms = new SqlParameter[] { new SqlParameter("@Parm1", this.cmbA.Text) }; ds = _mySQL.GetDataSet(_settings.myConnectionString, spName, "Data", sqlParms); this.cmbB.DataSource = null; this.cmbB.DataSource = ds; this.cmbB.ValueMember = "Value"; this.cmbB.DisplayMember = "Display"; break; default: break; } }
private void cmbB_InitializeLayout(object sender, InitializeLayoutEventArgs e) { e.Layout.Bands[0].ColHeadersVisible = false; e.Layout.Bands[0].Columns["Value"].Hidden = true; }
That's everything.
Internal error: can't convert to Destination Value.
************** Exception Text **************System.Exception: Internal error: can't convert to DestinationValue. at Infragistics.Win.EmbeddableEditorBase.GetDataFilteredDestinationValue(Object sourceVal, ConversionDirection direction, EmbeddableEditorOwnerBase owner, Object ownerContext) at Infragistics.Win.UltraWinGrid.UltraCombo.get_Value() at Infragistics.Win.UltraWinGrid.UltraGridComboEditorOwner.GetValue(Object ownerContext) at Infragistics.Win.EmbeddableEditorBase.GetDataFilterSourceValue(ConversionDirection direction, EmbeddableEditorOwnerBase owner, Object ownerContext) at Infragistics.Win.EmbeddableEditorBase.GetDataFilteredDestinationValue(ConversionDirection direction, Boolean& isValidConversion, EmbeddableEditorOwnerBase owner, Object ownerContext) at Infragistics.Win.EmbeddableEditorBase.GetDataFilteredDestinationValue(ConversionDirection direction, EmbeddableEditorOwnerBase owner, Object ownerContext) at Infragistics.Win.EditorWithCombo.GetElementValue(EmbeddableUIElementBase element) at Infragistics.Win.EditorWithCombo.GetElementText(EmbeddableUIElementBase element, Boolean ignorePasswordChar) at Infragistics.Win.EditorWithTextUIElement.PositionChildElements() at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) at Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics) at Infragistics.Win.UIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics) at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize, Boolean preventAlphaBlendGraphics) at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize) at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode) at Infragistics.Win.UltraControlBase.OnPaint(PaintEventArgs pe) at Infragistics.Win.UltraWinGrid.UltraCombo.OnPaint(PaintEventArgs e) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
...and a big red X graphic appears in place of cmbB.
Again, the only thing that happened was converting the controls from 9x to 2011.2. This code does not error before the conversion.
Think I am on to something with the new UltraDropDown. I added two drop downs to the same form and copied the code posted above into the same events. The application will not compile! The new drop downs "do not contain a definition for 'Value'". The conversion from 9.2 to 2011.2 is allowing this code but is failing during runtime.
The error is reproducible creating two new 2011.2 UltraCombo controls, setting the DropDownStyle to DropDownList, and using the exact same code I posted above. I do not get the error setting the DropDownStyle to DropDown on the converted controls or the new controls. The question is why?
Hi Michael,
Yes, sorry. I responded only to the case for this post (CAS-78720-GHHPF4). I will close this post as there are two solutions. Here is that text from the case:
I was able to quickly reproduce the issue, which turn out to be the same issue just found this morning in my other post "Unexpected behavior changes between 9.2 and 11.2?".
Michael S. In your sample, simply change Combo2's .Value member to "State". Because three of the records have "NJ" as their State, when Combo2 loses focus "Jersey City" is left in Combo2 as the selected record even if you select "Newark" or "Trenton". This is the smoking gun and does not happen for us in our current production application using 9.2. Changing the .Value and .DisplayMemeber to "City" is the equivalent of what I need to do to "fix" our upgraded 11.2 application.
The new property you mention also fixes the issue, is the better solution, and turns to fix a larger issue I was having with another UltraCombo, which I am unable to replicate using your sample.
[Michael S.] "Try setting the "ItemMatchingMode" property of ultraCombo2 to "ValueListItemMatchingMode.DoNotConvertDataValueToString"."
At this point I am good to go. Is there any documentation that can be shared regarding the new (to us / post 9.2) Combo property ItemMatchingMode?
[Michael S.] http://help.infragistics.com/NetAdvantage/WinForms/current/CLR2.0/?page=Infragistics2.Win.UltraWinGrid.v11.2~Infragistics.Win.UltraWinGrid.UltraDropDownBase~ItemMatchingMode.htmlThanks to everyone who helped me resolve this issue!
Jaime,
Did you try my suggestion?
In the sample that you are referring to try setting the "ItemMatchingMode" property of ultraCombo2 to ValueListItemMatchingMode.DoNotConvertDataValueToString
I will update the case notes with these findings. I do not know if it is appropriate to link case numbers in this forum for Mike S. to see, or would it be best for you to attach the sample from the case?
Thank you Micheal S. and Mike S.
This post was elevated to a Support Case, so I now have examples from both of you. This morning I was able to modify an example for another forum post of mine dealing with a single UltraCombo to reproduce that issue, which looks like the non-unique column I set as the Combo's .Value is causing that issue, which is not an issue with the current production application running 9.2.
I will work on one of your samples now to see if I can replicate this issue with the chained Combos.
Thanks again, Jaime