PDA

View Full Version : how to put tabindex for rows of data Grid?



maryam
06-23-2007, 08:23 PM
How can I put tabindex for datagrid so that I can go to the next cell with tab?

Aussiebear
06-24-2007, 04:11 AM
Hi Maryam,

I did a little searching via google and came across this:

Hi Kevin,

Is it MS flexgrid control ? If not please ignore my comment.

If so then you can use the TextMatrix property. ControlName.TextMatrix(1,2)=3 will put 3 into the Row2 and Column3 (rows and columns start counting from 0)

A sample code might be like the following one: Control name is flxControl in sample code.


code:
Private Sub UserForm_Initialize()
Dim rng As Range
Dim cll As Range
Dim i As Long

'Assuming data range is "E2:H18" on sheet1
Set rng = Sheet1.Range("E2:H18")

'flxControl is the flexgrid control name
With Me.flxControl
.ColWidth(0) = 300
.Rows = rng.Rows.Count + 1
.Cols = rng.Columns.Count + 1

'Row Numbers
For i = 1 To .Rows - 1
.TextMatrix(i, 0) = i + rng.Cells(1, 1).Row - 1
Next i
'Column Letters - simplified: doesn't work correctly after Z
For i = 1 To .Cols - 1
.TextMatrix(0, i) = Chr(64 + i + rng.Cells(1, 1).Column - 1)
Next i

'TextMatrix(Row,Column) : TextMatrix(0,0) is the top-left cell of flexgrid
For Each cll In rng.Cells
.TextMatrix(cll.Row - rng.Cells(1, 1).Row + 1, cll.Column - rng.Cells(1, 1).Column + 1) = cll.Value
Next cll
End With
End Sub

Don't know if it will answer your question but it might prompt one of the good guys for a responce.

maryam
06-24-2007, 09:33 PM
I am using datagrid not MSflexgrid and I dont find text matrix property for datagrid!

tqm1
06-25-2007, 03:45 AM
Dear Maryam

Could you please send me a sample of datagrid?

Thanks

maryam
06-25-2007, 05:12 AM
attached is datagrid.

maryam
06-28-2007, 06:51 AM
any solution for this? tabindex for dataGrid? :help :help