Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Newbie trying to use VirtualList

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
terryharrison



Joined: 25 Jun 2007
Posts: 3

PostPosted: Mon Jun 25, 2007 8:02 pm    Post subject: Newbie trying to use VirtualList Reply with quote

I have a virtual list hooked up to the virtual connection and I am trying to retrieve the selected data. The virtual connection retrieves two columns from the datatable and I set displaymember to show one of them. It doesn't honor that choice but will only display whatever is the first column in the choice. If I bind a regular dataset to the virtual list I can retrieve the info by CType(VirtualListBox2.SelectedItem, DataRowView).Item(0)) but when it is bound to the virtual connection this won't work. Can someone tell me how to display one column and then retrieve the second value column and how to do that from the virtual connection setup.
Thanks
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Jun 25, 2007 10:45 pm    Post subject: Reply with quote

The VirtualListBox control doesn't currently support binding using the DisplayMember property to lists that use the ITypedList interface - which is what VirtualRecordsets use to allow access to the fields . This is an oversight on our behalf - most of our customers are using Virtual Tree which does support binding via ITypeList. We will fix this in the next release.

Fortunately there is a fairly way to do this without setting the DisplayMember. You simply handle the GetItemText event for the VirtualListBox and set the text to display explicitly eg

Code:
private void _virtualListBox_GetItemText(object sender, Infralution.Controls.GetItemTextEventArgs e)
{
    Infralution.VirtualData.VirtualRecord vr = e.Item as Infralution.VirtualData.VirtualRecord;
    e.Text = vr["myColumn"];
}

_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
terryharrison



Joined: 25 Jun 2007
Posts: 3

PostPosted: Tue Jun 26, 2007 2:16 am    Post subject: Reply with quote

Ok I understand that so now I can fill the list with the correct column - how do I retrieve the column value not displayed when the user double clicks a row? The column I am displaying is the part sku for example and I want to let the user double click on the displayed sku but I want to retrieve the other column for the specific part lookup.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Jun 26, 2007 2:51 am    Post subject: Reply with quote

The SelectedItem is the VirtualRecord - so your if the other column was called "id" and contained a string value the code would be:

Code:
VirtualRecord vr = VirtualListBox2.SelectedItem as VirtualRecord ;
String id = vr["id"] as String;

_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
terryharrison



Joined: 25 Jun 2007
Posts: 3

PostPosted: Thu Jun 28, 2007 2:28 am    Post subject: What about showing the row as selected. Reply with quote

A new problem has popped up. I can bind the data from the virtual recordset to the virtual listbox and it works very well. I can intercept the click and the double click event and get the correct data. However when the top row of data is clicked it selects as normal - colors the background inverts the text, etc. If any other row below the top row is selected it does not display as being selected although the click and double click action will retrieve the correct info. I really need the row to show it is selected. Am I missing something in the set up?

Thanks
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Jun 28, 2007 6:02 am    Post subject: Reply with quote

That sounds very odd. I've tried replicating this (bound a VirtualListBox control to a VirtualData recordset in the way described in previous posts) but could not see the problem you are getting.

Are handle the Click event or overriding the VirtualListBox.OnClick method. If overriding make sure that you call the base method.

If you could you create a small sample program which shows the problem and email it to us at support@infralution.com that would help us track down the issue.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Thu Jun 28, 2007 11:59 pm    Post subject: Reply with quote

Thanks for the sample project - it made it easy to track down the problem. The issue is actually with the way you initialize the VirtualRecordset. Your code does the following:

Code:
Me.VirtualRecordset1.SelectClause = "Select mapicsorder,netgainID from aaborder order by mapicsorder desc"
Me.VirtualRecordset1.VirtualConnection = Me.VirtualConnection1
Me.VirtualConnection1.CursorLocation = ADODB.CursorLocationEnum.adUseClient
Me.VirtualListBox2.DataSource = Me.VirtualRecordset1


This code doesn't set the PrimaryKey for the VirtualRecordset. VDO uses the PrimaryKey to enable it to compare instances of VirtualRecords for equivalence (via Equals and GetHashCode functions). If the PrimaryKey is not set then these functions may return different values even when two VirtualRecords refer to the same underlying ADO record.

Virtual List box determines whether a row should be highlighted by checking if the SelectedItems collection contains the row item. However because the PrimaryKey has not been set this does not work correctly.

The solution is simple - set the PrimaryKey before assigning the DataSource as follows:

Code:
Me.VirtualRecordset1.PrimaryKey = "mapicsorder"


We currently don't force you to set a PrimaryKey because there are some instances where you may want to iterate through a Recordset that does not have a primary key - but such recordsets cannot be used for data binding.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group