Solved

flexgrid

Posted on 2002-07-27
17
392 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 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

13 Experts available now in Live!

Get 1:1 Help Now