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!
|
| |
|
Re: Combobox in datagrid - dynamically changing items
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 |
|
|
|
Re: Combobox in datagrid - dynamically changing items
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 |
|
|
|
Re: Combobox in datagrid - dynamically changing items
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.
|
|
|
|
Re: Combobox in datagrid - dynamically changing items
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.
|
|
|
| |
|
Re: Combobox in datagrid - dynamically changing items
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. |
|
|
|
Re: Combobox in datagrid - dynamically changing items
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 |
|
|
| |
|
Re: Combobox in datagrid - dynamically changing items
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? |
|
|
|
Re: Combobox in datagrid - dynamically changing items
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. |
|
|
| |
|
Re: Combobox in datagrid - dynamically changing items
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
|
|
|
|
Re: Combobox in datagrid - dynamically changing items
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 |
|
|
|
Re: Combobox in datagrid - dynamically changing items
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 |
|
|
|
Re: Combobox in datagrid - dynamically changing items
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. |
|
|
| |
|