New topic: 

How to enter text directly in a listbox?

<http://forums.realsoftware.com/viewtopic.php?t=30710>

       Page 1 of 1
   [ 5 posts ]                 Previous topic | Next topic         Author  
Message       MaryRaj           Post subject: How to enter text directly in a 
listbox?Posted: Tue Oct 27, 2009 11:46 pm                        
Joined: Wed Mar 04, 2009 1:17 am
Posts: 15              Hi,

I am trying to add data directly in a listbox and save it to the database by 
clicking the button..
i added the following code in the change event of the listbox..

change event :
Code:
Dim row,column as Integer

'me.InsertRow me.ListIndex,""

row=Me.RowFromXY(System.MouseX - Me.Left - Self.Left,_
  System.MouseY - Me.Top - Self.Top)
column=Me.ColumnFromXY(System.MouseX - Me.Left - Self.Left,_
  System.MouseY - Me.Top - Self.Top)

MsgBox "You clicked in cell "+Str(row)+", "+Str(column)

Me.CellType(row,column)=Listbox.TypeEditable
me.EditCell(row,column)

 

But when i try to click on a cell.. it gives me the message 
You clicked in cell -1,-1
and the error.. I understand this is because the listbox is empty..
can anyone help me to resolve this?   
                            Top                sbeach           Post subject: 
Re: How to enter text directly in a listbox?Posted: Tue Oct 27, 2009 11:58 pm   
                     
Joined: Wed May 10, 2006 1:27 pm
Posts: 32              I think you're over complicating this, but correct me if 
there's another program situation that requires the use of the Change() event.  
The Change() event fires on just about any UI change: if the user clicks a 
selected cell or even on empty/nonexistent cells.

Try putting the following code into either the CellClick() event:
Code:
Function CellClick( Row as Integer, Column as Integer, X as Integer, Y as 
Integer ) as Boolean
  me.EditCell(row,column)
End Function



You also dont need:
Code:Me.CellType(row,column)=Listbox.TypeEditable

That makes it so the cell is automatically opened for editing when it is double 
clicked.  For example, if you add a row:
Code:
me.AddRow "This Is A New Row"
me.CellType(me.lastIndex,0) = Listbox.TypeEditable


Double clicking that cell would automatically open it up for editing, you 
wouldn't even need the previous code in CellClick().     
_________________
-Sean  
                            Top               MaryRaj           Post subject: 
Re: How to enter text directly in a listbox?Posted: Wed Oct 28, 2009 12:35 am   
                     
Joined: Wed Mar 04, 2009 1:17 am
Posts: 15              Quote:Try putting the following code into either the 
CellClick() event:
Code:

Function CellClick( Row as Integer, Column as Integer, X as Integer, Y as 
Integer ) as Boolean
  me.EditCell(row,column)
End Function


I tried this one.. but no effect.. when i clicked or double clicked nothing 
happened to the listbox.. I dont understand why..

And 
can u say in which event to add this code 
  me.AddRow "This Is A New Row"
  me.CellType(me.lastIndex,0) = Listbox.TypeEditable
and try..
I tried in change event but it goes on adding..   
                            Top                sbeach           Post subject: 
Re: How to enter text directly in a listbox?Posted: Wed Oct 28, 2009 12:46 am   
                     
Joined: Wed May 10, 2006 1:27 pm
Posts: 32              MaryRaj wrote:I tried this one.. but no effect.. when i 
clicked or double clicked nothing happened to the listbox.. I dont understand 
why..
Was the listbox empty at the time?

MaryRaj wrote:can u say in which event to add this code
me.AddRow "This Is A New Row"
me.CellType(me.lastIndex,0) = Listbox.TypeEditable
and try..
I tried in change event but it goes on adding..

Try putting it in the open event for now, just so you can see how it works.     
_________________
-Sean  
                            Top               MaryRaj           Post subject: 
Re: How to enter text directly in a listbox?Posted: Wed Oct 28, 2009 3:39 am    
                    
Joined: Wed Mar 04, 2009 1:17 am
Posts: 15              Quote:MaryRaj wrote:
I tried this one.. but no effect.. when i clicked or double clicked nothing 
happened to the listbox.. I dont understand why..

Was the listbox empty at the time?


yes the listbox is an empty one and I am trying to add data in the empty 
listbox..   
                            Top            Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 5 posts ]     
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to