You are not logged in.

riaanp

Beginner

  • "riaanp" is male
  • "riaanp" started this thread

Posts: 21

Date of registration: Nov 14th 2009

Location: Krugersdorp, South Africa

Occupation: Linux Opensource Consultant

Hobbies: Programming

  • Send private message

1

Monday, December 28th 2009, 9:37pm

Jabaco JBGRID

Does anyone know if you can set focus on the JBGRID once the form loads? There does not seem to be a property to do that like .SetFocus

Is there maybe a general way to set focus on ANY component textbox, button, label etc?
I am ROOT if you see me laughing you better have a backup! :cursing:

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

2

Monday, December 28th 2009, 11:04pm

Hi,
I've tried the following to answer you question:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Public Sub Form_Load()
   Dim row As Integer
   Dim col As Integer 
   Dim rowIndex As Integer = 2
   Dim columnIndex As Integer = 3
      
   JBGrid1.Cols = 4
   JBGrid1.Rows = 6
   JBGrid1.SelectionMode = flexSelectionFree
   JBGrid1.Editable= jbEditOnClick
   
   For row = 0 To JBGrid1.Rows - 1
      For col = 0 To JBGrid1.Cols - 1
         
         JBGrid1.DataMatrix(row, col) = row & ";" & col
         JBGrid1.DataMatrix(row, col).CanGetFocus = True
         JBGrid1.DataMatrix(row, col).Editable= True
         JBGrid1.DataMatrix(row, col).Enabled= True         
         JBGrid1.DataMatrix(row, col).TextAlign= fmTextAlignCenter
      Next col
   Next row
   
   JBGrid1.Refresh
   JBGrid1.Parent.clearSelection() 
   JBGrid1.Parent.changeSelection(rowIndex, columnIndex, False, False) 
   JBGrid1.DataMatrix(rowIndex, columnIndex).Parent.requestFocus
   JBGrid1.DataMatrix(rowIndex, columnIndex).SetFocus
   Me.Refresh
End Sub


It might inspire you for own experiments, but the code does not work.
To focus on a button, you simply write "Command1.Parent.requestFocus()", but I could not make that work for the JBGrid as a whole nor for a single DataMatrix element. Might be a misunderstanding on my side or a deficiency in the Jabaco framework.

Greetings!

A1880

riaanp

Beginner

  • "riaanp" is male
  • "riaanp" started this thread

Posts: 21

Date of registration: Nov 14th 2009

Location: Krugersdorp, South Africa

Occupation: Linux Opensource Consultant

Hobbies: Programming

  • Send private message

3

Monday, December 28th 2009, 11:13pm

Nope that was a perfect example. Same problem still. I will continue to experiment. I know the WINAPI have a function like this but i would like to stay away from WINAPI's as much as possible. And I have found a JAVA class thingy that will do the job. Just need to add it in somehow :)

Thx for the suggestion though! :)
I am ROOT if you see me laughing you better have a backup! :cursing:

riaanp

Beginner

  • "riaanp" is male
  • "riaanp" started this thread

Posts: 21

Date of registration: Nov 14th 2009

Location: Krugersdorp, South Africa

Occupation: Linux Opensource Consultant

Hobbies: Programming

  • Send private message

4

Monday, December 28th 2009, 11:16pm

Great code! That actual answered my next question! LOL
How to focus on a specific line
I am ROOT if you see me laughing you better have a backup! :cursing:

Anton

Beginner

Posts: 5

Date of registration: Mar 6th 2010

  • Send private message

5

Saturday, March 6th 2010, 7:25pm

This was great help thanks!
But how would I remove a row?

JBGrid1.Row(2).Remove
doesn't work.

Edit:
How do you use JBGrid1.Parent.remove ?

This post has been edited 1 times, last edit by "Anton" (Mar 6th 2010, 7:50pm)


A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

6

Sunday, March 7th 2010, 1:47am

The Parent of a JBGrid is a JTable.
The usual way of removing rows from a JTable is to go via its DefaultTableModel.
Unfortunately, the model of a JTable in Jabaco is a JBGridModel which hasn't got a DefaultTableModel.

Long answer short: I don't know how to remove rows from an existing JBGrid.
Recreating/redrawing might be the workaround for the time being.

Looking through the documentation of javax.swing I get more and more thankful that the Jabaco framework hides major parts of swing's complexity.
However, until the Jabaco framework gets more waterproof, one has to look underneath into low-level java APIs.

Cheers

A1880

Rate this thread
WoltLab Burning Board