StrataFrame Forum

Listview

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

By Rafael - 8/26/2008

I have two TabControl.

In second tabControl have a listview

In first tabControl have a textbox where will to be a code for populate listview, how i do for listview populate whith :

Select * from tabpedidocompraitem where code = ( is here a value of textbox Wink

By Bill Cunnien - 8/26/2008

Rafael (08/26/2008)
I have two TabControl.

In second tabControl have a listview

In first tabControl have a textbox where will to be a code for populate listview, how i do for listview populate whith :

Select * from tabpedidocompraitem where code = ( is here a value of textbox Wink

You would use a custom fill method in the tabpedidocompraitem business object.  Like this:


public void FillByTextBoxValue(string pTextBoxValue)
{
   
SqlCommand cmd = new SqlCommand("SELECT * FROM tabpedidocompraitem WHERE code = @textboxvalue");
    cmd.CommandType =
CommandType.Text;
    cmd.Parameters.AddWithValue(
"@textboxvalue", pTextBoxValue).SqlDbType = SqlDbType.VarChar;
    FillDataTable(cmd);
}

Follow the SF documentation under "ListView Population".  Marvelous step-by-step to help you with the whole setup.

Hope that helps,
Bill

By Bill Cunnien - 8/26/2008

Blush  Sorry...didn't mean to quote your whole post...I was using that as a guide and forgot to delete it before I posted.

Bill

(note to forum admins: it would be nice to have a view of the post to which we are replying...thanks!)

By Greg McGuffey - 8/26/2008

The other part of the picture is to setup the listview appropriately. This would be a two parter...



1. Obviously you'd set the ListView to use the custom method that Bill mentioned and you'd handle the ListPopulating event of the listview to get the value from the textbox.



2. You'd then need to set the listview to load manually (rather than on form load), by setting the PopulateOnFormLoad property to Manual. Of course then you need to manually fill it. To do this you'd call .Requery() as appropriate. Likely in either the TextBox.Leave event or perhaps when the tab page is activated.



Hope that helps! BigGrin
By Trent L. Taylor - 8/26/2008

(note to forum admins: it would be nice to have a view of the post to which we are replying...thanks!)

You do...scroll down and open the last 10 posts in descending order section.

By Rafael - 8/26/2008

I understand and very very thanks.

I will do in event Leave of textbox, but i have a question.

What is a bether method to used populate of listview ?

Please say me a method that used in populate listview and i search in documentation.

If i have doubt, question in the forum.

By Greg McGuffey - 8/26/2008

Rafael,



Not sure what your asking, if anything. Do you still have a question?
By Greg McGuffey - 8/26/2008

You do...scroll down and open the last 10 posts in descending order section.




Wow, never noticed that! That's cool! w00t



Thanks for asking Bill...I've often done the quoting thing myself. The last 10 posts is much better. I also noticed that you can also open the complete topic in a new window...even better for those lonnnnng posts.
By Bill Cunnien - 8/26/2008

You do...scroll down and open the last 10 posts in descending order section.

Whoa. Blink

Thanks! w00t

By Bill Cunnien - 8/26/2008

What is a bether method to used populate of listview ?

Please say me a method that used in populate listview and i search in documentation.

You could pass the parameter in the Requery method of the ListView:

MyListView.Requery(myCoolParameter);

But, as I found out over time, it is better to pass the parameter in the ListPopulating event of the ListView (from docs using VB):


Private Sub ListView1_ListPopulating(ByVal e As MicroFour.StrataFrame.UI.ListPopulatingEventArgs) Handles ListView1.ListPopulating
    '-- Pass the search text to the FillByLastName() method
    e.Parameters(0).Value = Me.txtSearch.Text
End Sub

Then, whenever you need to refresh the ListView control, it is a simple call to its Requery method:

MyListView.Requery();

No need to remember to pass a parameter since it is handled in the event.  Good stuff.  A "set it and forget it" type of approach.

By Rafael - 8/26/2008

For population in Load Form, i configured populationDataSourceSetings and implemnt this code:

        private void lvPedidoCompraItem_ListPopulating(ListPopulatingEventArgs e)
        {
            e.Parameters[0].Value = this.sysPedidoCompraItemBO1;
            e.Parameters[1].Value = MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromDefaultView;
        }

        private void lvPedidoCompraItem_RowPopulating(RowPopulatingEventArgs e)
        {
            //-- Establish Locals
            sysPedidoCompraItemBO loBO = ((sysPedidoCompraItemBO)e.BusinessObject);

            //-- Set the not count
            //e.Values[1].DisplayValue = CustomerNotes.GetNoteCount(loBO.cust_pk).ToString("n0");
        }

But i use   

e.Parameters[0].Value = for_cod.Text;
and delete
sysPedidoCompraItemBO loBO = ((sysPedidoCompraItemBO)e.BusinessObject);
, when initialize form with error.
By Edhy Rijo - 8/26/2008

So it is now working for you?
By Rafael - 8/26/2008

no
By Edhy Rijo - 8/26/2008

Ok, even though I use VB your code looks good, all you have to do now is just requery the ListView control in one of the places mentioned by Bill, in the Textbox control or in the Page's Activate.

Are you getting any specific error? or just the listview is not being populated?

By Rafael - 8/26/2008

The error is first post this topic Smile

http://forum.strataframe.net/Topic18700-6-1.aspx

By Edhy Rijo - 8/26/2008

Rafael (08/26/2008)
The error is first post this topic Smile

http://forum.strataframe.net/Topic18700-6-1.aspx[/quote]

Rafael, you could not be getting the same error:[quote]BusinessLayerException

  The ParentBusinessObject property must be set before FillByParent can be called with no parameters supplied.

since the method to populate the BO could not be FillByParent. Can you post an screenshot of the List View Population Settings, I would like to see what you have in the Method to Execute. 

Here is an example of what I use in one of my forms:

In this case I use the CopyDataFrom(BusinesLayerBase,BusinessCloneDataType) because I have an instance of the bizBuildings BO in the form and I simply update that BO instance and the listview will copy all records to the ListView internal BO.  I find this method easier to maintain.

P.S

I'll be online for a couple of hours in case you want to pursue with this issue.

By Bill Cunnien - 8/27/2008

If your "Method to Execute" on the ListView is set to the BO fill method as I outlined above (FillByTextBoxValue(string pTextBoxValue)), then all you need in the ListPopulating event is the following:


private void lvPedidoCompraItem_ListPopulating(ListPopulatingEventArgs e)
{
    e.Parameters[0].Value = for_cod.Text;
}

On the leave focus event of the textbox (or whereever you need it), all you have to do is:


lvPedidoCompraItem.Requery();