flexgrid

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
LVL 1
eladrAsked:
Who is Participating?
 
yongyihCommented:
if u want second column to have right alignment.

flxgrd.colalignment(2)=7

remember to set the properties FillStlye = flexFillRepeat

0
 
yongyihCommented:
try this..
listOfSales is grid name.

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

good luck.
0
 
yongyihCommented:
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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
jayeshshahCommented:
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
 
jayeshshahCommented:
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
 
eladrAuthor Commented:
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
 
yongyihCommented:
...
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
 
eladrAuthor Commented:
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
 
yongyihCommented:
Private Sub Form_Load()
    MSFlexGrid1.FillStyle = flexFillRepeat
    MSFlexGrid1.ColAlignment(2) = 7
    MSFlexGrid1.TextMatrix(1, 2) = "A"
    MSFlexGrid1.TextMatrix(2, 2) = "A"
End Sub
0
 
mdouganCommented:
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
 
eladrAuthor Commented:
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
 
mdouganCommented:
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
 
yongyihCommented:
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
 
eladrAuthor Commented:
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
 
yongyihCommented:
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
 
mdouganCommented:
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
 
cymru_cowboyCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.