Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Monday, November 25, 2024 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - Controls
Forum to discuss usage & tips for SalesLogix controls and other 3rd party ActiveX controls. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to Controls | New ThreadView:  Search:  
 Author  Thread: Combobox in datagrid - dynamically changing items
Glenn Williams
Posts: 51
 
Combobox in datagrid - dynamically changing itemsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 05 Oct 08 10:20 AM
I've got a datagrid and I want to change the combo list items dynamically when the user clicks the row or dropdown.

Thanks.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Combobox in datagrid - dynamically changing itemsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 06 Oct 08 12:26 AM
When a row is selected you can just get a reference to the column and fill it's items collection as you would any combobox. Something like this:

Dim col

Set col = DataGrid1.Columns(3)
col.Items.Clear
col.Items.Add "Item 1"
col.Items.Add "Item 2"
col.Items.Add "Item 3"
'etc...


-Ryan
[Reply][Quote]
vbextra
Posts: 10
 
Re: Combobox in datagrid - dynamically changing itemsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 Oct 08 9:18 PM
Hi Ryan,

I had the same requirement. I was able to add values like above. But, When I select value while editing or adding new row, it is not stick in to cell after selecting value. Do you know why?

I tried picklist column also. It is same behaviour.

regards
VB
[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Combobox in datagrid - dynamically changing itemsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Oct 08 11:03 AM
1. AFIK none of this stuff works with a NEW (insert) Row......this is inline editing of an existing row (an update).

2. Changing a specific COLUMN in a grid, specifying Picklist Type (15), saying OK, editing that Column's type, specifying a Picklist, and having the ReadOnly box NOT CHECKED.....works in Inline Editing just fine.

Anything else is a craps shoot...... specifically, for complex items I put the control desired in a panel above the grid....call this the EDIT panel. When you select/click on a specific grid row, you throw the values from the grid to the controls.....after you change the control values and hit an edit/update button I then throw (update) the new values down to the grid. Works everytime with no fuss.

This works great for Combo Boxes, LookupEdits, Radio Button selections, et al.

[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Combobox in datagrid - dynamically changing itemsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Oct 08 11:03 AM
1. AFIK none of this stuff works with a NEW (insert) Row......this is inline editing of an existing row (an update).

2. Changing a specific COLUMN in a grid, specifying Picklist Type (15), saying OK, editing that Column's type, specifying a Picklist, and having the ReadOnly box NOT CHECKED.....works in Inline Editing just fine.

Anything else is a craps shoot...... specifically, for complex items I put the control desired in a panel above the grid....call this the EDIT panel. When you select/click on a specific grid row, you throw the values from the grid to the controls.....after you change the control values and hit an edit/update button I then throw (update) the new values down to the grid. Works everytime with no fuss.

This works great for Combo Boxes, LookupEdits, Radio Button selections, et al.

[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Combobox in datagrid - dynamically changing itemsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Oct 08 11:04 AM
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[Reply][Quote]
Robert Levine
Posts: 132
 
Re: Combobox in datagrid - dynamically changing itemsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Feb 09 2:40 PM
Its been awhile. RJ, I'm seeing triple. Ryan: your suggestion worked like a charm. Every time I go near that Opportunity Product grid, I get the sweats. But this time things are turning out fine. Thanks.
[Reply][Quote]
Isuru Seeman Hewage
Posts: 6
 
Re: Combobox in datagrid - dynamically changing itemsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 08 May 12 9:30 PM
fiogf49gjkf0d

Hi Ryan,


With above code, it actually fills up the entire column for all the rows in the data grid with same combo box data. What if i want to populate combo box row by row with different items. How to access a inidividual combobox cell and add items to it?


Please help me.


 


Regards,


Izzy

[Reply][Quote]
Raul A. Chavez
Posts: 1300
Top 10 forum poster: 1300 posts
 
Re: Combobox in datagrid - dynamically changing itemsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 May 12 9:34 AM
fiogf49gjkf0d

Izzy:


 


  The key is that you do this as each row is selected, this allows you to figure out which row you are on and then decide what values to add to the Combo Box.

[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Combobox in datagrid - dynamically changing itemsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 May 12 5:49 PM
fiogf49gjkf0d

Hi Izzy,


What Raul mentioned is spot on. You can't have different rows' drop down be different exactly since the drop down is part of the column. So instead, you do this as each row is selected. Whenever the user selects a row, your code populates the column drop down base on the current selected row. If the user then selects a different row, the code clears the drop down and does it all over again based on that row. Make sense?

[Reply][Quote]
Isuru Seeman Hewage
Posts: 6
 
Re: Combobox in datagrid - dynamically changing itemsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 May 12 6:57 PM
fiogf49gjkf0d

Hi Raul & Ryan,


Thanks for the replies. Yes i do understand what you mean. I'm a .NET person and not quite clear how to do this in VB6 for saleslogix development. Can you provide me a sample code to select inidividual cell on a datagrid and add items to combo box? I assume i might have to put the code in some sort of a row select event. So which event should be the best event to put this in?


Ex: Let's say I have data grid and I want put 5 combo box items to 3rd row, 3rd column. Can you provide me a sample code for this?


Many thanks for helping me out.

[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Combobox in datagrid - dynamically changing itemsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 May 12 7:59 AM
fiogf49gjkf0d

Who's talking .Net and\or VB6? This has NOTHING to do with either.......

[Reply][Quote]
Isuru Seeman Hewage
Posts: 6
 
Re: Combobox in datagrid - dynamically changing itemsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 May 12 6:52 PM
fiogf49gjkf0d

Hi RJ,


Can you provide me a sample code to select inidividual cell on a datagrid and add items to combo box? I assume i might have to put the code in some sort of a row select event. So which event should be the best event to put this in?


I'm currently trying to do this in VB6


 

[Reply][Quote]
Vaughn Poulson
Posts: 32
 
Re: Combobox in datagrid - dynamically changing itemsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 15 May 12 9:06 AM
fiogf49gjkf0d

Here is an example of how i dynmically load a combo box using a sql query.  I do this on the Data Grids OnEditing event.


 


Function DataGrid_Editing(Sender, PrimaryKeyValue, FieldName, Value)


If  FieldName  = "ComboBox" Then


Dim sql, rs


Set rs = objSlxDb.GetNewRecordSet


sql = "Select someColumn " & _


                          "From SomeTable  " & _


                        "Where SomeCondition "


rs.Open sql, objSlxDb.Connection


DataGrid.Columns.Item("ComboBox").Items.Clear


While Not rs.EOF


DataGrid.Columns.Item("ComboBox").Items.Add rs.Fields("someColumn").Value


rs.MoveNext


Wend


Set rs = Nothing


End IF


End Function 


 


Hope this helps. 


Vaughn

[Reply][Quote]
Isuru Seeman Hewage
Posts: 6
 
Re: Combobox in datagrid - dynamically changing itemsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 16 May 12 12:10 AM
fiogf49gjkf0d

HI Vaughn,


Thanks for the reply. But that still doesn't solve my problem isn't it. When you say DataGrid.Columns.Item("ComboBox").Items.Add it ads the value to all the columns. What if i want to add the value only to the column in 3rd row, rather than adding values to all the columns? This is what i want to do, and i didn't get any answer so far for this.


Regards,


Izzy

[Reply][Quote]
Vaughn Poulson
Posts: 32
 
Re: Combobox in datagrid - dynamically changing itemsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 29 May 12 1:46 PM
fiogf49gjkf0d

This is true that all the columns will have the same values, but if you load those values in the OnEditing event based on some value specific to that row, then it will be dynamic.  Here is another example i just did today:



    If UCase(FieldName) = "GL_ACCOUNT" and dgPoInvoiceLines.GetCurrentField("JOB_SOLD") = "F" Then


        dgPoInvoiceLines.Columns.Item("GL_ACCOUNT").Items.Clear


        dgPoInvoiceLines.Columns.Item("GL_ACCOUNT_KEY").Items.Clear


        If glRs.RecordCount > 0 Then


            glRs.MoveFirst


            While Not glRs.EOF


                If UCase(glRs.Fields("Description").Value) <> "WORK IN PROCESS" Then


                    dgPoInvoiceLines.Columns.Item("GL_ACCOUNT").Items.Add glRs.Fields("GlAcctNo").Value


                    dgPoInvoiceLines.Columns.Item("GL_ACCOUNT_KEY").Items.Add glRs.Fields("GLAcctKey").Value


                End If


                glRs.MoveNext


            Wend


        End If


    ElseIf UCase(FieldName) = "GL_ACCOUNT" and dgPoInvoiceLines.GetCurrentField("JOB_SOLD") = "T" Then


        dgPoInvoiceLines.Columns.Item("GL_ACCOUNT").Items.Clear


        dgPoInvoiceLines.Columns.Item("GL_ACCOUNT_KEY").Items.Clear


        If glRs.RecordCount > 0 Then


            glRs.MoveFirst


            While Not glRs.EOF


                If UCase(glRs.Fields("Description").Value) = "WORK IN PROCESS" Then


                    dgPoInvoiceLines.Columns.Item("GL_ACCOUNT").Items.Add glRs.Fields("GlAcctNo").Value


                    dgPoInvoiceLines.Columns.Item("GL_ACCOUNT_KEY").Items.Add glRs.Fields("GLAcctKey").Value


                    glRs.MoveLast


                End If


                glRs.MoveNext


            Wend


        End If


    End If



 


The column i care about loading data for is GL_ACCOUNT.  If the column JOB_SOLD is 'T' is load one set of values, else i load a different set.  

[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Combobox in datagrid - dynamically changing itemsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 29 May 12 4:12 PM
fiogf49gjkf0d

Neat, I've never attempted that. in general I don't use inline editable grids anyway. Thanks for posting!

[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2024 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 11/25/2024 7:17:16 PM