Click here to Skip to main content
15,905,322 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I have a problem tat need your help.
I have a table with 6(1->6) column and column 2,3,5 are combobox column.
when click on any cell on this columns, a combobox will appear and allow user choice
data from this combobox end then return normal cell.

if you know, please help me!
(I am a Java beginer)

thanks in advance
Posted
Comments
CodingLover 31-Oct-11 1:47am    
Have you tried anything yet?
ngthtra 31-Oct-11 6:10am    
I have tried but combobox of the row that was added can not set value but can set text to it
ex: at col2: combobox value are{(text:A, value:1), (text:b, value:2),(text:C, value:3)} but when add new row,combobox of col 2 only has text and not has value(combobox value are: {A,B,C}, it is not value). So when select text i can not set combobox value for table.

do you have other idea?

1 solution

If you want to separate the value and text that are shown in the combobox you have to create an object that holds both values.

The code below shows how to do this. Just create objects of this class and add them to the combobox. With getId() you get the ID of the object and with getDescription() you get the text. The toString() method makes sure that the description will be the text shown in the combobox.


Java
class Item {
		private int id;
		private String description;

		public Item(int id, String description) {
			this.id = id;
			this.description = description;
		}

		public int getId() {
			return id;
		}

		public String getDescription() {
			return description;
		}

		public String toString() {
			return description;
		}
	}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900