Solved

flexgrid

Posted on 2002-07-27
17
393 Views
Last Modified: 2008-03-10
im using the msflex grid to retrive records from db.
i want the data inside the cell will be in the right side of the cell.
i tried the propery:
flxgrd.CellAlignment = 0\1\2\right
but it's not working

elad
0
Comment
Question by:eladr
  • 7
  • 4
  • 3
  • +2
17 Comments
 
LVL 2

Expert Comment

by:yongyih
ID: 7182869
try this..
listOfSales is grid name.

  listOfSales.Col = 3
  listOfSales.Row = 3
  listOfSales.CellAlignment = 7
  listOfSales.TextMatrix(3, 3) = "Hi"

good luck.
0
 
LVL 2

Expert Comment

by:yongyih
ID: 7182875
for your case is flxgrd.CellAlignment = 7

more information:

Constant Value Description
flexAlignLeftTop 0 The cell content is aligned left, top.

flexAlignLeftCenter 1 Default for strings. The cell content is aligned left, center.

flexAlignLeftBottom 2 The cell content is aligned left, bottom.

flexAlignCenterTop 3 The cell content is aligned center, top.

flexAlignCenterCenter 4 The cell content is aligned center, center.

flexAlignCenterBottom 5 The cell content is aligned center, bottom.

flexAlignRightTop 6 The cell content is aligned right, top.

flexAlignRightCenter 7 Default for numbers. The cell content is aligned right, center.

flexAlignRightBottom 8 The cell content is aligned right, bottom.

flexAlignGeneral 9 The cell content is of general alignment. This is "left, center" for strings and "right, center" for numbers

hope this can help you. ^_^
0
 
LVL 5

Expert Comment

by:jayeshshah
ID: 7183168
Set the row and column and then the alignment.

in case you want to align the complete row then no need to set the column & instead of CellAlignment you can use the ColAlignment
0
 
LVL 5

Expert Comment

by:jayeshshah
ID: 7183169
Sorry previous one was a mistyping

Set the row and column and then the alignment.

in case you want to align the complete column then no need to set the row & instead of CellAlignment you can use the ColAlignment
0
 
LVL 1

Author Comment

by:eladr
ID: 7183324
t doesnt work.
real make me crazy.
here is the relevent code:

...
Set rs = CreateObject("adodb.recordset")
    rs.Open sql, conn
   
    flxgrd.Cols = rs.Fields.Count - 3
    flxgrd.Rows = 1
   
    flxgrd.ColWidth(0) = 0
    flxgrd.ColWidth(4) = 4970
   
    flxgrd.ColWidth(1) = 2500

...
i tried
flxgrd.cellAligment = 7
and also
flxgrd.colalignment = ???(what to write?)
and nothing...
elad
0
 
LVL 2

Expert Comment

by:yongyih
ID: 7183348
...
Set rs = CreateObject("adodb.recordset")
   rs.Open sql, conn
   'this set the number of columns
   flxgrd.Cols = rs.Fields.Count - 3
   'this set the number of rows
   flxgrd.Rows = 1
   
   flxgrd.ColWidth(0) = 0
   flxgrd.ColWidth(4) = 4970
   
   flxgrd.ColWidth(1) = 2500

...
i tried
'''' you have to specify alignment for which cell.
'''''no 's'
flxgrd.row =   'which row
flxgrd.col =   'which col
flxgrd.cellAligment = 7
and also
flxgrd.colalignment = ???(what to write?)
and nothing...
elad
0
 
LVL 1

Author Comment

by:eladr
ID: 7183827
hi...
IT'S NOT WORKING!!!
i want all the data in all the table will be in the right side.(im using hebrew which is written from Right to left)
why it's so hard to do such simple thing???????????

elad
p.s.:flxgrd.colalignment = ???(what to write?)

0
 
LVL 2

Accepted Solution

by:
yongyih earned 35 total points
ID: 7184353
if u want second column to have right alignment.

flxgrd.colalignment(2)=7

remember to set the properties FillStlye = flexFillRepeat

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 2

Expert Comment

by:yongyih
ID: 7184376
Private Sub Form_Load()
    MSFlexGrid1.FillStyle = flexFillRepeat
    MSFlexGrid1.ColAlignment(2) = 7
    MSFlexGrid1.TextMatrix(1, 2) = "A"
    MSFlexGrid1.TextMatrix(2, 2) = "A"
End Sub
0
 
LVL 18

Expert Comment

by:mdougan
ID: 7186194
It's also possible to set the column's alignment by using special characters in the FormatString property:

mygrid.FormatString = "^Employee ID|<Employee Name|>Employee Age"

This will give you a centered column, a left aligned column and a right aligned column respectively.
0
 
LVL 1

Author Comment

by:eladr
ID: 7186240
o.k.
i opened new project with new flexgrid and the data is in right side.
but when im trying to do it in my project it's refuse to go to the right.
this is my function which fill the grid.
thanks
elad




Private Sub fillGrid()
'connection to db
    connectTo
    Dim sql As String
    Dim r As Integer
   
   
   
    sql = "select m.id as MID,m.patientID,m.SHour,m.Ehour,m.comments,p.id,p.Fname,p.Lname from meetings m ,patients p  where m.patientID = p.id"

   
    Set rs = CreateObject("adodb.recordset")
    rs.Open sql, conn
   
   
    flxgrd.Cols = rs.Fields.Count - 3
    flxgrd.Rows = 1
   
    'trying to put it here**********
    flxgrd.ColAlignment(3) = 7
    '*******************************
   
    flxgrd.ColWidth(0) = 0
    flxgrd.ColWidth(4) = 4970
   
    flxgrd.ColWidth(1) = 2500
   
    'trying to put it here**********
    flxgrd.ColAlignment(3) = 7
    '*******************************
   
    Do While Not rs.EOF
        r = r + 1
        flxgrd.Rows = flxgrd.Rows + 1
   
        flxgrd.TextMatrix(r, 0) = rs("MID").Value & ""
        flxgrd.TextMatrix(r, 1) = rs("Fname").Value & " " & rs("Lname").Value & ""
        flxgrd.TextMatrix(r, 2) = rs("shour").Value & ""
        'trying to put it here**********
        flxgrd.ColAlignment(3) = 7
        '*******************************
        flxgrd.TextMatrix(r, 3) = rs("eHour").Value & ""
        flxgrd.TextMatrix(r, 4) = rs("comments").Value & ""
        rs.MoveNext
    Loop
        'Closing recordset and connection
         rs.Close
         Set rs = Nothing
         conn.Close
         Set conn = Nothing
         
End Sub
0
 
LVL 18

Expert Comment

by:mdougan
ID: 7186778
I always set the column widths and alignment after the grid is completely loaded.  It might be that you have set some property that tells the grid to autoformat based on the content, so, if you set the property after the content is in, then you'll have more chance of getting what you want.

If it works when you add a fresh control to a project, then compare the properties of the fresh grid to the properties of your existing grid and see where they differ.  Also, consider just deleting the grid you have and putting a new one down with the same name.
0
 
LVL 2

Expert Comment

by:yongyih
ID: 7186789
How about try to use AddItem method.


flxgrd.addItem rs("MID").value & vbtab & rs("Fname").value
...

or you convert it to string.  str(rs("MID").value)

or remove flxgrd.colAlignment(3)=7 from loop.
because i think colAlignment, set one time is enough.

Good Luck.
0
 
LVL 1

Author Comment

by:eladr
ID: 7187354
it's working.
the problem was that the propery RightTopLeft was set to true
and that's made the problems.
im increase the pts. and i want to add another que:
when the user select one row it color it with blue and then clicking on the delete will delete the row from db.
however there is a problem when the user drag his mouse and select several rows.
i want NOT to let the user pick several rows but only one.
any ideas?

elad

0
 
LVL 2

Expert Comment

by:yongyih
ID: 7187575
i don't know this at the moment.. but i can try to figure out.

may be you should accept comment as answer for this question first and ask another new question.


thanks.
0
 
LVL 18

Expert Comment

by:mdougan
ID: 7187685
There should be a SelectMode (or selectionmode) and you should set this to either the option that is something like List or Listview, or the option that is something like By Row.  Then, it's possible that you will manually have to iterate through each row and set the IsSelected = False for every row that is not the current row.  So, in the RowColChange event:

Dim i

For i = 1 to tblGrid.Rows = 1
    if i <> Row then
       tblGrid.IsSelected(i) = False
    End if
Next i

0
 

Expert Comment

by:cymru_cowboy
ID: 7716463
This method isn't the tidiest but it's the best way I've found so far of restricting user input to one row

Private Sub flexgrid_SelChange()
    flexgrid.RowSel = glexgrid.Row
End Sub
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA loop through headers using value 3 57
Use closed file on desktop in vba 6 67
Excel object stays open 19 71
VB error "Type mismatch" 2 50
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now