﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » Combobox not populating when on a SF User Control</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Wed, 24 Jun 2026 01:13:07 GMT</lastBuildDate><ttl>20</ttl><item><title>Combobox not populating when on a SF User Control</title><link>http://forum.strataframe.net/FindPost11253.aspx</link><description>I scanned the forum, but could not find&amp;nbsp;my particular issue addressed. I have a DevX SF wrapped combobox on a SF User control.&amp;nbsp;&amp;nbsp;I am programmically adding the user control to a form.&amp;nbsp; Along with the combobox I have textboxes on the control also.&amp;nbsp; The textboxes show the data from the BO object, but the combobox does not.&amp;nbsp; To make sure I was not missing something in the combobox settings and had&amp;nbsp;all of the data binding setup correctly, I put&amp;nbsp;the combobox and the same BO on a SF Maintenance form with the exact same&amp;nbsp;settings and the combobox populates correctly.&amp;nbsp; What is going on?&lt;IMG title=Crazy src="http://forum.strataframe.net/Skins/Classic/Images/MessageIcons/Crazy.gif" align=absMiddle&gt;&lt;/P&gt;&lt;P&gt;Thanks!</description><pubDate>Tue, 04 Sep 2007 13:50:04 GMT</pubDate><dc:creator>Jeff Pagley</dc:creator></item><item><title>RE: Combobox not populating when on a SF User Control</title><link>http://forum.strataframe.net/FindPost11323.aspx</link><description>Thanks for the details on casting.  I'm not using the TryCast enough...  :D</description><pubDate>Tue, 04 Sep 2007 13:50:04 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Combobox not populating when on a SF User Control</title><link>http://forum.strataframe.net/FindPost11313.aspx</link><description>That's strange.&amp;nbsp; The IsDirty property does not have a backing field.&amp;nbsp; Meaning that we don't store off the value anywhere.&amp;nbsp; Each time you call the get{} of the property, the CurrentDataTable of the business object is re-evaluated for dirty rows.&amp;nbsp; So, either one of the records is not being saved, or possibly, you're saving on a transaction.&amp;nbsp; If you save on a transaction, the changes do not get accepted until the transaction is comitted.&amp;nbsp; What I would check first is the return value of the Save() method.&amp;nbsp; It should return Success.&amp;nbsp; So, if it's returning CompletedWithExceptions or AbortedWithBrokenRules, the records are not actually being persisted to the database, and the business object will still be dirty.</description><pubDate>Tue, 04 Sep 2007 08:31:32 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Combobox not populating when on a SF User Control</title><link>http://forum.strataframe.net/FindPost11310.aspx</link><description>Thanks for the tip Ben.&amp;nbsp; In addition, I had an issue with the IsDirty property. See &lt;A href="http://forum.strataframe.net/FindPost11280.aspx"&gt;http://forum.strataframe.net/FindPost11280.aspx&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Thanks again.</description><pubDate>Tue, 04 Sep 2007 07:27:30 GMT</pubDate><dc:creator>Jeff Pagley</dc:creator></item><item><title>RE: Combobox not populating when on a SF User Control</title><link>http://forum.strataframe.net/FindPost11297.aspx</link><description>Oh, and I forgot jpp that in VB controls are marked with Friend (internal) while in C#, they're marked as private by default.&amp;nbsp; So, for the first sample of mine to work, you would need to change the modifier to either internal or public to see your combo box as a field directly on the form.</description><pubDate>Mon, 03 Sep 2007 23:27:18 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Combobox not populating when on a SF User Control</title><link>http://forum.strataframe.net/FindPost11296.aspx</link><description>Greg is correct about the use of DirectCast vs CType in VB.&amp;nbsp; DirectCast tells the compiler to try casting the object and then check for implcit/explicit casting operators on the two types in question (the one being cast and the requested type) while CType tells the compiler to try casting it first, and then check for an implicit/explicit conversion operators, and then try the Convert.ToXXX methods for backward compatibility with old VB,&amp;nbsp;so in some cases, CType is slower :).&amp;nbsp;&amp;nbsp;Nice one Greg.&lt;/P&gt;&lt;P&gt;However, jjp, you're using C#, which doesn't have DirectCast or CType, it just has the cast syntax like C++:&lt;/P&gt;&lt;P&gt;string var = (string)someOtherVar;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;object var = new SomeType();&lt;BR&gt;((SomeType)var).SomeMethodOnThatType();&lt;/P&gt;&lt;P&gt;So, in C#, the casting operator is the equivalent to DirectCast (though the C# compiler will pick up on a few extra things that DirectCast won't).&amp;nbsp; There is no equivalent to CType, but since it's really meant for backward compatibility with old VB, and since the C# casting picks up on a few cases where DirectCast won't you don't really need it.&lt;/P&gt;&lt;P&gt;One other casting worth mentioning is the "as" (C#) / TryCast (VB):&lt;/P&gt;&lt;P&gt;object var = new SomeType();&lt;BR&gt;SomeType var2 = var as SomeType;&lt;/P&gt;&lt;P&gt;Dim var As Object = New SomeType()&lt;BR&gt;Dim var2 As SomeType = TryCast(var, SomeType)&lt;/P&gt;&lt;P&gt;It can only be used with reference types (so no value types, structures, etc.).&amp;nbsp; But, it will never throw an exception (hence the "Try" in the name) and it's extremely fast.&amp;nbsp; It will try to cast the object, and if it fails, it returns null (Nothing in VB), hence why you need a reference type since value types cannot be null.&amp;nbsp; So, if you're not absolutely positive that your object is going to be a certain type, always TryCast (as) and then test your variable on null (Nothing).&amp;nbsp;&amp;nbsp;That combination is actually just as fast as casting and is much faster than testing on the type of an object before casting it.&amp;nbsp; If you use Reflector and look through the .NET DLLs, you'll see them use it all the time.&lt;BR&gt;</description><pubDate>Mon, 03 Sep 2007 23:25:38 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Combobox not populating when on a SF User Control</title><link>http://forum.strataframe.net/FindPost11289.aspx</link><description>Any time.  I understand about limited time. You'll get it soon enough :hehe:&lt;br&gt;
&lt;br&gt;
As to the IsDirty question. My understanding is that it should be set to false after a save.  I do know that it is just looking at the datatable that the BO wraps. Ben (or Trent if he's back) will have to field that one.  It doesn't make any sense to me.&lt;br&gt;
&lt;br&gt;</description><pubDate>Fri, 31 Aug 2007 16:50:45 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Combobox not populating when on a SF User Control</title><link>http://forum.strataframe.net/FindPost11287.aspx</link><description>Greg&lt;/P&gt;&lt;P&gt;Thanks so much for the info.&amp;nbsp; I know I am going to have to spend more time studying the object browser and learning this stuff.&amp;nbsp; Unfortunately, my time is split between technical support and programming and so I am not able to focus for any length of time on .NET.&amp;nbsp; That is why we used Strataframe and rely heavily on the forums for help.&lt;/P&gt;&lt;P&gt;Also,&amp;nbsp;do you know answer to the other part of my reponse concerning the BO.Save and the BO.IsDirty question?</description><pubDate>Fri, 31 Aug 2007 13:57:22 GMT</pubDate><dc:creator>Jeff Pagley</dc:creator></item><item><title>RE: Combobox not populating when on a SF User Control</title><link>http://forum.strataframe.net/FindPost11285.aspx</link><description>Sorry about the code. I just typed it in, so I likely made a mistake.  &lt;br&gt;
&lt;br&gt;
The concept that is important here is that .NET is strongly typed.  That means that the compiler will see a control as a control, even if it is a subclass of a control, like a combobox.  The Controls collection is a collection of System.Control objects.  A combobox is NOT a System.Control, though it inherits from it.  Thus when you attempted to access a method of a combobox on the object returned from the Controls collection, it bombed, as System.Control doesn't have the Requery() method.  Since you know that the object really is a combobox however, you can cast it to the correct type.&lt;br&gt;
&lt;br&gt;
There are two ways to cast things in VB: DirectCast() and CType().  Apparently DirectCast is faster in some instances.  You can cast an object to its native type, any type it inherits from or to any interface it implements. The object browser is your friend when figuring stuff like this out.  &lt;br&gt;
&lt;br&gt;
Finally, I've been using "combobox" very loosely here.  Actually, you'd need to define the actual, specific type. If you were using a normal .NET combo, I believe it would be System.Windows.Forms.ComboBox.  If you are using the SF combobox, it would be something like Microfour.StrataFrame.UI.Windows.Forms.ComboBox.  I think there might be sub classes for devex and infragistics in SF too, in which case you'd use those specific types when casting.  Again, use the object browser and intellisense to figure out exactly what type you need to cast to. At first this was a pain, but I've come to really like the strong typed approach.&lt;br&gt;
&lt;br&gt;
I also came from mostly MS Access background, so I'm familiar with the pain of getting up to speed in .NET.  After about 9 months heads down with .NET and SF I'm starting to get it  :D  The cool thing I've found is that tasks usually easier in .NET, once you figure them out...:crazy:...hence the pain!  Without this forum, the pain would have been fatal :Whistling:&lt;br&gt;
&lt;br&gt;
I'm glad you got it working.  A property or method is often the way to go if you need to let the parent form manipulate something on the user control.&lt;br&gt;
&lt;br&gt;</description><pubDate>Fri, 31 Aug 2007 13:38:41 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Combobox not populating when on a SF User Control</title><link>http://forum.strataframe.net/FindPost11280.aspx</link><description>Hi Greg/Ben,&lt;/P&gt;&lt;P&gt;Unfortunately, the code did not work.&amp;nbsp; It throws another exception.&amp;nbsp; However, when you had mention using an method&amp;nbsp;on the user control it got me to thinking.&lt;/P&gt;&lt;P&gt;In the user control load event, I filled the BO object and&amp;nbsp;I executed&amp;nbsp;the cbo.requery() method and it worked.&amp;nbsp;&amp;nbsp;&lt;IMG title=W00t src="http://forum.strataframe.net/Skins/Classic/Images/MessageIcons/W00t.gif" align=absMiddle&gt;&lt;/P&gt;&lt;P&gt;As a part-time programmer and new to Strataframe, some things just don't dawn on me.&amp;nbsp; I came from the VB and MSAccess world.&amp;nbsp; So I am still trying to figure all of this .NET stuff out.&amp;nbsp; It is quite a learning curve when you don't work with this stuff all of the time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Oh by the way, since I have your attention.&amp;nbsp; I noticed that after I execute a BO.Save method, the BO.IsDirty property is still true.&amp;nbsp; What else do I need to do when saving the changes to BO for the IsDirty to reset to False?&amp;nbsp; I'm checking this property to make sure the end user saves his changes.&lt;/P&gt;&lt;P&gt;Thanks guys for helping a newbie like me.</description><pubDate>Fri, 31 Aug 2007 12:08:44 GMT</pubDate><dc:creator>Jeff Pagley</dc:creator></item><item><title>RE: Combobox not populating when on a SF User Control</title><link>http://forum.strataframe.net/FindPost11277.aspx</link><description>[quote]DirectCast(uControl.Controls("cboClients").Requery(),ComboBox).Requery()[/quote]&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Doh...mistyped that, it should be:&lt;br&gt;
&lt;br&gt;
DirectCast(uControl.Controls("cboClients"),ComboBox).Requery()</description><pubDate>Fri, 31 Aug 2007 11:31:31 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Combobox not populating when on a SF User Control</title><link>http://forum.strataframe.net/FindPost11276.aspx</link><description>You'll need to cast the control to a combo - DirectCast(uControl.Controls("cboClients").Requery(),ComboBox).Requery()&lt;br&gt;
&lt;br&gt;
You'd need to replace the "ComboBox" with the actual type, something like Microfour.StrataFrame.UI.Windows.Forms.Combobox. &lt;br&gt;
&lt;br&gt;
Alternately, you could provide a property on the user control that exposes the combobox or a method that does the requery.&lt;br&gt;
&lt;br&gt;</description><pubDate>Fri, 31 Aug 2007 11:30:25 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item><item><title>RE: Combobox not populating when on a SF User Control</title><link>http://forum.strataframe.net/FindPost11274.aspx</link><description>Hi Ben,&lt;/P&gt;&lt;P&gt;This what I tried but the compiler doesn't like it.&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;uControl.Controls(&lt;/FONT&gt;&lt;FONT color=#800000 size=2&gt;"cboClients"&lt;/FONT&gt;&lt;FONT size=2&gt;).requery()&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size=2&gt;The compiler message&amp;nbsp;is as follows:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;'requery' is not a member of 'System.Windows.Forms.Control'.&lt;FONT size=2&gt;&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Fri, 31 Aug 2007 10:31:31 GMT</pubDate><dc:creator>Jeff Pagley</dc:creator></item><item><title>RE: Combobox not populating when on a SF User Control</title><link>http://forum.strataframe.net/FindPost11273.aspx</link><description>Aha, in that case, the ComboBox will not populate on its own.&amp;nbsp; You'll have to call Requery() on it.&amp;nbsp; So, add uControl.cbCombo.Requery() before the code that you posted and it should get you fixed.</description><pubDate>Fri, 31 Aug 2007 10:14:14 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Combobox not populating when on a SF User Control</title><link>http://forum.strataframe.net/FindPost11272.aspx</link><description>I not sure how to do what you are suggesting.&amp;nbsp; The parent form is already loaded.&amp;nbsp; Then through a control's Click event I am adding the control to the parent form.&amp;nbsp; The code is below:&lt;/P&gt;&lt;FONT size=2&gt;&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#1111ff size=2&gt;Me&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;FONT color=#1111ff&gt;.gcCampaignContainer.Controls.Add(uControl)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#1111ff&gt;uControl.BringToFront()&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color=#1111ff&gt;uControl.Dock = DockStyle.Fill&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The uControl contains the combobox and BO.&lt;/P&gt;&lt;/FONT&gt;</description><pubDate>Fri, 31 Aug 2007 10:05:19 GMT</pubDate><dc:creator>Jeff Pagley</dc:creator></item><item><title>RE: Combobox not populating when on a SF User Control</title><link>http://forum.strataframe.net/FindPost11268.aspx</link><description>Most likely, it's either the order in which you're adding the user control to the form or the ParentContainer property on the user control.&amp;nbsp; So, what you need to do is add the user control before the OnLoad (Load event) of the form and when you create and add the user control, set the ParentContainer property on the user control to the form.&amp;nbsp; Then, when the Load event fires on the form, the combo box will know to populate itself.</description><pubDate>Fri, 31 Aug 2007 09:46:43 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item></channel></rss>