You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

1

Monday, October 29th 2012, 1:24pm

combobox in a jbgrid cell

Have a nice week all of us!

i would like to have a combobox in my JBGrid cell with row = 0 and col = 2 .... (0,2)

that fills like that

Set Data = Order.executeQuery("SELECT * FROM katigories WHERE katigories <> '***** ΚΑΜΙΑ *****' GROUP BY katigories ORDER BY katigories")
Do While Data.next()
katigories = Data.getString("katigories")
ComboBox_katigoria.AddItem New ListCellData(katigories, all_katigories, False)
Loop


How can i do something like this?

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

2

Monday, October 29th 2012, 7:09pm

finally i found the solution but it appears when i dblclick on every cell.
BUT I WANT TO HAVE THIS COMBOLIST ONLY IN (ROW,2)...
so to have it when i double click only the "column = 2" not to ALL CELLS

Does anybody know how can i do for example if col = 2 then.......COMBOLIST?

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

3

Monday, October 29th 2012, 9:04pm

Hey there,

try this:

Jabaco Source

1
2
3
4
5
6
JBGrid1.Editable = jbEditOnClick
'   Dim ComboBox1 As javax#swing#JComboBox = New javax#swing#JComboBox
ComboBox1.AddItem("Yes")
ComboBox1.AddItem("No")   
'AFTER!!!!!!  DataMatrix or TextMatrix of JBGrid1 is addressed set your new CellEditor
JBGrid1.Parent.getColumnModel().getColumn(2).setCellEditor(New DEFAULTCellEditor(ComboBox1))


Dani

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

4

Tuesday, October 30th 2012, 4:02pm

hi dani!
I tried to do your solution but i have "compile_error" and mark this...
JBGrid1.Parent.getColumnModel().getColumn(2).setCellEditor(New DEFAULTCellEditor(ComboBox1))
Have you got any idea what i am doing wrong?

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

5

Tuesday, October 30th 2012, 4:30pm

Hey there,

I am not sure what to tell you ?(

It works fine for me...

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
'draw a JBGrid1
'draw a ComboBox1

Public Sub Form_Load()
   JBGrid1.Editable = jbEditOnClick
'   JBGrid1.SelectionMode = flexSelectionByRow
'      Dim ComboBox1 As javax#swing#JComboBox = New javax#swing#JComboBox
   ComboBox1.AddItem("Yes")
   ComboBox1.AddItem("No")
   JBGrid1.TextMatrix(0,2) = ""
   'AFTER!!!!!!  DataMatrix or TextMatrix of JBGrid1 is addressed set your new CellEditor
   JBGrid1.Parent.getColumnModel().getColumn(2).setCellEditor(New DEFAULTCellEditor(ComboBox1))
End Sub




Try to do the above and save it as a little project.Unload Jabaco and load it again. Sometimes that works!


Dani

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

6

Tuesday, October 30th 2012, 4:37pm

could you please send me the example in zip because i did what exactly you told me but i am still having "COMPILE_ERROR"

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

7

Tuesday, October 30th 2012, 5:03pm

as i see this code occurs the problem on me...
JBGrid1.Parent.getColumnModel().getColumn(2).setCellEditor(New DEFAULTCellEditor(ComboBox1))

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

8

Tuesday, October 30th 2012, 5:53pm

Hey there,

hm, we are back to the framework question!
But I believe you are using the latest one by now right?

You might try not to draw the ComboBox and uncomment the 'Dim...' line. :S

GridCbo.zip


Dani

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

9

Tuesday, October 30th 2012, 6:14pm

Hey there,

Ok, my guess is that this should do it:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
'draw a JBGrid1

Public Sub Form_Load()
   JBGrid1.Editable = jbEditOnClick
'   JBGrid1.SelectionMode = flexSelectionByRow
   Dim ComboBox1 As javax#swing#JComboBox = New javax#swing#JComboBox
   ComboBox1.AddItem("Yes")
   ComboBox1.AddItem("No")
   JBGrid1.TextMatrix(0,2) = ""
   'AFTER!!!!!!  DataMatrix or TextMatrix of JBGrid1 is addressed set your new CellEditor
   JBGrid1.Parent.getColumnModel().getColumn(2).setCellEditor(New javax#swing#DefaultCellEditor(ComboBox1))
End Sub


Dani

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

10

Wednesday, October 31st 2012, 12:01pm

Yes it solved my problem...

JBGrid1.Parent.getColumnModel().getColumn(2).setCellEditor(New javax#swing#DefaultCellEditor(ComboBox1))

thank you very much!

1.----------------------------------------------------------
is there a way to open the combobox without auto selected the first item?

for example if i have...


Public Sub Form_Load()
JBGrid1.Editable = jbEditOnClick
' JBGrid1.SelectionMode = flexSelectionByRow
Dim ComboBox1 As javax#swing#JComboBox = New javax#swing#JComboBox

ComboBox1.AddItem("ΕΣΟΔΑ")
ComboBox1.AddItem("ΕΞΟΔΑ")
JBGrid1.TextMatrix(0,2) = "test"
'AFTER!!!!!! DataMatrix or TextMatrix of JBGrid1 is addressed set your new CellEditor
JBGrid1.Parent.getColumnModel().getColumn(2).setCellEditor(New javax#swing#DefaultCellEditor(ComboBox1))
End Sub

i just want to open the combo without auto selecting ΕΣΟΔΑ as first value and loosing my "test" value

2.----------------------------------------------------------

can i have a function like this...

public sub Combobox1_change()
msgbox combobox1.text
end sub


thanks again!

This post has been edited 1 times, last edit by "fomaxrge" (Oct 31st 2012, 12:11pm)


Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

11

Wednesday, October 31st 2012, 2:17pm

Hey there,

I don't know how to display any text on the ComboBox.
ComboBox1.Text = "test" does not seem to work!!

I'll have a look at the framework.

This will preserve the grid content when ComboBox1_Click is fired and
this will also keep ComboBox1.List from having any item preselected:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
'draw a JBGrid1
'draw a ComboBox1

Public Sub Form_Load()
   JBGrid1.Editable = jbEditOnClick
   JBGrid1.TextMatrix(0,2) = "test"
   'AFTER!!!!!!  DataMatrix or TextMatrix of JBGrid1 is addressed set your new CellEditor
   JBGrid1.Parent.getColumnModel().getColumn(2).setCellEditor(New javax#swing#DefaultCellEditor(ComboBox1))
   ComboBox1.AddItem("Yes")
   ComboBox1.AddItem("No")
End Sub

Public Sub ComboBox1_Click()
   ComboBox1.Parent.setSelectedIndex(-1)
End Sub


Dani

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

12

Wednesday, October 31st 2012, 3:02pm

hi dani i tried to add this....
Public Sub ComboBox1_Click()
ComboBox1.Parent.setSelectedIndex(-1)
End Sub

and even thought it keeps the first selected value when i click on the cell i see it empty
how can i see when i click on it...

test
Yes
No




Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

13

Wednesday, October 31st 2012, 3:16pm

Hey there,

ComboBox1.Text sets the ComboBox1.ListIndex if the String matches the ListItem.
Since ComboBox1.ListIndex can not be set to 0 or -1 (see Bugreport) we are using ComboBox1.Parent.setSelectedIndex(-1) wich displays an empty ComboBox1.
There is no property of ComboBox that allows us to display text other than ListItems.
I think in VB6 that was possible!

So when you pass the JBGrid CellContent to the ComboBox it would oben with that String and set its ListIndex accordingly.
I don't see how it would make sense to display text on the JBGrid Cell that is not in ComboBox1.List.
Usually ComboBox1.List should be populated with all valid data for that field.

Dani

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

14

Wednesday, October 31st 2012, 3:23pm

Dani can you please help me how to do something like this...


Public Sub Form_Load()
ComboBox1.AddItem("first entry")
ComboBox1.AddItem("second entry")
ComboBox1.AddItem("third entry")

End Sub

Public Sub ComboBox1_Change()
MsgBox("your selection is " + ComboBox1.Parent.getItemAt(ComboBox1.ListIndex))
End Sub

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

15

Wednesday, October 31st 2012, 3:59pm

Hey there,

I think you are thinking too complicated here:

Jabaco Source

1
2
3
Public Sub ComboBox1_Change()
   MsgBox("your selection is " + ComboBox1)
End Sub

The thing is:
when ever you .add to the ComboBox ComboBox1_Change() is invoked!!
I don't know if that is a BUG or intentionally designed like this...
But you have to find some way to work arround that:

Jabaco Source

1
2
'If you know how many Items are to be loaded
If Combobox1.ListCount < 3 then Exit Sub



Dani

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

16

Wednesday, October 31st 2012, 4:02pm

Jabaco Source

1
2
3
4
Public Sub ComboBox1_Change()
   If Combobox1.ListCount < 3 then Exit Sub
   MsgBox("your selection is " + ComboBox1)
End Sub

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

17

Thursday, November 1st 2012, 3:47pm

Have a good month Dani!
i tried to find a way to print selected value of combobox2 whenever it change but i did not succeed.
i am trying to do something like this...

public sun combobox2_change()
JBGrid1.Editable = jbEditOnClick
JBGrid1.Parent.getColumnModel().getColumn(4).setCellEditor(New javax#swing#DefaultCellEditor(ComboBox3))
Set Data = Order.executeQuery("SELECT * FROM katigories WHERE katigories = combobox2 GROUP BY ipokatigories ORDER BY ipokatigories")
Do While Data.next()
MsgBox JBGrid1.Parent.getColumnModel().getColumn(4).setCellEditor(New javax#swing#DefaultCellEditor(ComboBox3))
ComboBox3.Visible = True
ipokatigories = Data.getString("ipokatigories")
ComboBox3.AddItem(ipokatigories)
Loop
end sub

So the combobox3 data depends on the selected item of combobox2.

Have you got any idea?

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

18

Friday, November 2nd 2012, 3:02pm

Hey there,

Please try to post your code in the Jabaco Code Box for better readability.
Use the <JBC> button in the editor to do so!!

I don't know the rest of your code. But remember I told you...

Quoted

'AFTER!!!!!! DataMatrix or TextMatrix of JBGrid1 is addressed set your new CellEditor


If you don't fill your Grid with data your CellEditor will not work!

What are you trying to do here? Do you really want the MsgBox to pop up every loop?

Quoted

Do While Data.next()
MsgBox JBGrid1.Parent.getColumnModel().getColumn(4).setCellEditor(New javax#swing#DefaultCellEditor(ComboBox3))
...


Are you looking for this

Jabaco Source

1
MsgBox(JBGrid1.TextMatrix(JBGrid1.Row, 4))


Dani

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

19

Monday, November 5th 2012, 11:02am

Thank you Dani for your precious help i think that i did what i was looking for.
I am testing it now.

Thanks again.

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

20

Wednesday, November 14th 2012, 4:41pm

Hi again i wonder is it possible to handle my combobox with double click instead of click.
I tried but it doesn't work on me.

Also it would perfect if someone knows how can i hide my combobox (before i put it in my JBGrid i do not want to show in on my form) is it possible?

Thank you!

Rate this thread
WoltLab Burning Board