StrataFrame Forum

EnhancedList Problem

http://forum.strataframe.net/Topic22382.aspx

By Geoff Hirst - 3/15/2009

Guys,

Been banging my head on this one. Just can't see why it doesn't work. I have followed the previous messages on doing this but the errors just change depending on what I do next.

I have the latest beta 1.6.7 of SF and V8.3.4 of DeveloperExpress Components.

I have discovered that the Enhancelist doesn't work properly if you choose methods such as CopyDataFrom. Is this by design?

Having looked at the source, the CreateDataSource method, only allows for a methodname, and a single parameter to follow. CopyDatafrom needs 2 parameters, thereby it all goes to cock if you use this and it throws the business object couldn't be populated exception.

Now, I have modified the source for the EL, but I must admit I would prefer a solution from you guys if possible. The problem I am getting is in the actual list, I cannot see the data. There are no apparent columns defined (even if I do them myself) but I can click on the list area and it looks like something is being selected, I just can't see it.

I have tried many combinations of columns named 'Col' (with a number), tried using the actual column names in my BO, nothing seems to want to play.

Can I use the EnhancedList for the same purpose I would use the default Devx Gridcontrol, or is the EL constrained to be a simple list?

As always, more than happy to be wrong, or to have missed something really simple

thanks for any help guys

Geoff

By Trent L. Taylor - 3/15/2009

I have discovered that the Enhancelist doesn't work properly if you choose methods such as CopyDataFrom. Is this by design?

No.  This is something that we do every day...and I know that we have a lot of SF developers that do this on the DevExpress EnhancedList...so if this is not working then this would be the first of it.  Generally when something like this comes up, it is generally due to DevExpress changing how the grid works (which is all that the EnhanceList actually is).

By Geoff Hirst - 3/15/2009

Trent,

THanks for the response. Now, I don't like being the first to say something isn't right, so I am going to go down the route that I have done something or not done something to cause the problem. Star Trek is always right in that the capabilities of the many outweigh the capabilities of the one. I also understand that the underlying component is Developer Express Grid and that they may make breaking changes.

So, my original post misses off a critical item and that is static properties seem to be ok. The issue I was having was when trying to do this dynamically using a ListViewPopulationSettings object.

I was also talking mince when I said it was the createdatasource method, the code I changed was in the GetFilledBusinessObject function instead. (it was sunday and I had been on this most of the day)

Here is my changed code, it has 'GH on the end. Not the prettiest but it stopped the exception occuring.

Dim laAllParams() As String 'GH

Dim laparams() As String = {"Item1", "Item2"} 'GH

Dim loBO As BusinessLayer

Dim loListEventArgs As ListPopulatingEventArgs = Nothing

Dim lnCnt As Integer

Dim loType() As System.Type = New System.Type() {}

Try

With _PopulationDataSourceSettings

'-- Create a reference to the business object

loBO = CType(Activator.CreateInstance(GetTypeFromReferencedAssemblies(.BusinessObjectType)), BusinessLayer)

'-- Find the parameters

laAllParams = .MethodToExecute.Split(";"c) '(1).Split(New Char() {","c}, StringSplitOptions.RemoveEmptyEntries) 'GH

Array.ConstrainedCopy(laAllParams, 1, laparams, 0, laAllParams.GetUpperBound(0)) ' GH

'-- Get the method name

lcMethodName = .MethodToExecute.Split(";"c)(0)

This is the code I was using to create the ListViewPopulationSettings Object

With lvps

.BusinessObjectType = "CodePage_Security_BOL.P2_1"

For Each fieldname As String In Me.P2_11.AllFieldsList

.DisplayFieldNames.Add(fieldname)

.FormatColumns.Add("{" & fieldcounter & "}", MicroFour.StrataFrame.UI.ListViewColumnPopulationType.FormattedString)

.FormatString = "{" & fieldcounter & "}"

fieldcounter += 1

Next

.MethodToExecute = "CopyDataFrom;MicroFour.StrataFrame.Business.BusinessLayerBase;MicroFour.StrataFrame.Business.BusinessCloneDataType"

.ValueMember = "UserID"

End With

Me.el.PopulationDataSourceSettings = lvps

Me.el.Requery()

'

Private Sub el_ListPopulating(ByVal e As MicroFour.StrataFrame.UI.ListPopulatingEventArgs) Handles el.ListPopulating

e.Parameters(0).Value = Me.P2_11

e.Parameters(1).Value = MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromDefaultView

End Sub

So, after deciding that modifying the Inherited UI is probably making things worse, I decided to re-install. I am now back to my original error of failing to populate the EnhancedList. So, either there is a problem with the GetFilledBusinessObject function OR my ListviewPopulationSettings creation is incorrect. I think I know where I would rather put my money, so over to you guys. What am I doing wrong?

Thanks chaps.

Geoff

By Trent L. Taylor - 3/16/2009

I guess I am not totally following.  What was the stack trace of the error that you were getting?  Also, do you get the same error with a ListView (standard SF not the EnhancedList)?
By Geoff Hirst - 3/16/2009

Trent,

Sorry for my incoherence.

Here is the stack trace that I get from using a SF Listview

"   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)    at System.ThrowHelper.ThrowArgumentOutOfRangeException()    at System.Collections.Generic.List`1.get_Item(Int32 index)    at CodePage_Security_POC.POC_Menu.lvw_ListPopulating(ListPopulatingEventArgs e) in F:\CodePage\CodePage_Security_POC\CodePage_Security_POC\POC_Menu.vb:line 148    at MicroFour.StrataFrame.UI.Windows.Forms.ListView.GetFilledBusinessObject(Object[] Parameters)"

{"Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"}

Now this was thrown in the listpopulating event, where it attempts to assign a value to the second parameter of the CopyDataFrom method.

Given that this is occuring with a Listview as well, my Listviewpopulationsettings object has to be wrong. What have I missed?

Above all this, the real problem I have is that when I have managed to get the Enhancedlist populated, there is nothing visible in the grid. You can click on the grid, and the selection bar moves, but there are no column headings etc. The data is in the grid, as I have established this through debug.writeline, you just can't see it on the grid. I know this is something to do with Developer Express as I remember this happening to me a long time ago, but I can't remember the solution.

thanks in advance

Geoff.

By Trent L. Taylor - 3/16/2009

Given that this is occuring with a Listview as well, my Listviewpopulationsettings object has to be wrong. What have I missed?

Yeah.  Could you post a sample of this so I can make sure I direct you correctly?  Also, you can look at the StrataFlix sample as this is done a lot within those samples...including using the CopyDataFrom method.

By Geoff Hirst - 3/16/2009

Hi Trent,

I have now resolved the first issue. The error was all mine, as expected, and it was the methodtoexecute property. I had used semi-colons as the delimeter all the way across, rather than just after the method name. I have now resolved this so thats great thanks for the help there.

My final issue, is actually seeing the data in the enhancedlist. Everything is being populated I can click rows in the grid and if I debug, the data is present.

Want I cannot see is the data in the grid. I know this is a devexpress thing, I just can't remember what.

The area where the blue bar is where the data should be. I just can't see it. Any ideas?

thanks for helping me sort the previous issues.

best

Geoff

By Rainer Kempf, RK - 3/17/2009

Hello Geoff,



I have sometimes the same problem as you.



On miy side helps when i add control again on form.



But it would be interresting to know what cuases this problem.



If you have solution for this it would be nice to would tell us.





Thanks

Rainer
By Geoff Hirst - 3/18/2009

Hi Rainer,

No solution at this time, awaiting response from Microfour guys. At the moment have removed EnhancedList and replaced with base XtraGrid.

Requires a bit more messing around but have majority of results I wanted. Would prefer to have EL working though.

If I resolve, I will post here.

best

Geoff.

By Trent L. Taylor - 3/18/2009

The area where the blue bar is where the data should be. I just can't see it. Any ideas?

It looks like you do not have any columns.  Did you clear our the columns or even create any columns for the ListView?  The SF ListView is actually far more advanced than the DevEx EnhancedList.  But from a first glance, it looks like there are no columns within the grid.

By Geoff Hirst - 3/18/2009

Hi Trent,

Columns are populated generically from the business object allfieldslist.

I would use the Listview but I need an autocolumnwidth capability that I can't see on the list view.

thanks

Geoff.

By Geoff Hirst - 3/18/2009

hi,

ok, moved on a fair bit.

First up. The listview can have an autocolumnwidth. Populate your LV THEN set the columnwidth to -1 or -2. -2 did it for me. However, I can't use the LV because I need to export to PDF, and Excel etc. Possible enhancement chaps? Smile.

So, back to the Enhancedlist. You need to set additional properties when you add columns programmatically. The properties I had omitted were

.Visible = True ' Doh, - defaults to false

.VisibleIndex = something other than the default of -1 ' doh

.Width = something other than 0 ' doh - why I figured it would default to 60 like everything else seems to do I don't know.

Magically, columns appear.

Almost there now.

thanks for the contributions.

Geoff.