FieldName property not working on EnhancedList


Author
Message
Andria Jensen
Andria Jensen
Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)
Group: Forum Members
Posts: 336, Visits: 497
When I try to access the FieldName property for a specific column in an EnhancedList control I am not getting the correct value.  I get Col0, Col1, Col2, and so on instead of the correct FieldName values.  I really need this as I would like to access a column based on the FieldName and I don't know what index it will be.  I tried this in DevExpress and it worked correctly, so it is probably something to do with what's going on in the Population of the grid from the BO.
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yes, we name the colums Col# because each column can be a concatenation of multiple fields, and it is not always just one field.  The only way to determine which field is stored within which column is to check the population data source settings and see which column maps to which field.
Andria Jensen
Andria Jensen
Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)
Group: Forum Members
Posts: 336, Visits: 497
Ok, then how would you suggest that I accomplish this piece of code instead?  This is done at a base form level and I need it to be generic. I won't necessarily know what column number goes with what field or populated value.

gridView.FocusedRowHandle = gridView.LocateByValue(0, gridView.Columns(BusinessObject.PrimaryKeyField), Value)


StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You could do it like this:

With Me.EnhancedList1.PopulationDataSourceSettings
    Me.GridView1.LocateByValue(0, _
       
Me.GridView1.Columns(Array.IndexOf(.FormatColumns.ToArray(), _
        "{" *
.DisplayFieldNames.IndexOf(BusinessObject.PrimaryKeyField).ToString() & "}")), Value)
End With

It will use the population data source settings to determine the column that contains the primary key field.


Andria Jensen
Andria Jensen
Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)
Group: Forum Members
Posts: 336, Visits: 497
That won't quite work. You're trying to use the BusinessObject.PrimaryKeyField as an Integer index into the DisplayFieldNames array.  It's just a string value for the Primary Key field name.  I guess I'm not understanding how these things work together.
Andria Jensen
Andria Jensen
Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)
Group: Forum Members
Posts: 336, Visits: 497
Let me just add something further to explain this.  This post is actually stemming off Post#2537 where I'm trying to keep the focus from moving to the top of my EnhancedList after a requery.  That's why I started trying to do this code.  Also to note here is that my primary key field is not a visible column.  With DevExpress you can still access this column even though you can't see it.  But, with the EnhancedList that column won't be a part of DisplayFieldNames or FormatColumns or anything to do with the PopulationDataSourceSettings except for the Tag field.  I'm not sure where to go with this, but I have to make it work.
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Well, the primary key field must be added as a column within the PopulationDataSourceSettings, or you will not be able to select it out of the columns.  In fact, the DataTable that is dynamically created to be the DataSource of the EnhancedList will not even contain the primary key value.  You're best bet might to be to use the basic DevExpress GridControl without the EnhancedList and just create a business object that contains the data you need and set it as the DataSource of the grid (through a BusinessBindingSource) which will allow you to control everything that is visible/non-visible within the grid and also control the column names themselves.
Andria Jensen
Andria Jensen
Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)
Group: Forum Members
Posts: 336, Visits: 497
Ok, so now I'm switching all these EnhancedList controls over to a straight DevExpress GridControl....thank god for inheritance!  I am having a problem though (surprise).  I am setting the data source to my BO's CurrentDataTable, but it's not populating correctly.  It almost like the rows are all there but the data isn't showing up in them.  I can scroll down and select through the grid, but the cells are blank.  The DataTable shows data when I look at it in debug, but something's not going right with the population.  Is there something else I need to do with the BO besides set the CurrentDataTable as the DataSource?  There used to be something like IsListSource, but that's gone now...is there something else?
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
You will want to use a BusinssBindingSource control.  Simply drop it on the form and then select the BO it is supposed to wrap.  This basically emits each row with the strong-typed field properties and supports the two-way data-binding as well.
Andria Jensen
Andria Jensen
Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)
Group: Forum Members
Posts: 336, Visits: 497
Great, I got it working.  Does that mean the grid will automatically refresh when the BO changes if you use a BusinessBindingSource?  No calling RefreshDataSource?
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search