Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MSDataGridLib.DataGrid
#1
how do i set column width and height for the datagrid ?
[Image: 2007-02-28_143357.jpg]

here is my current code:
msdatagrid_dialog
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam

;typelib MSDataListLib {F0D2F211-CCB0-11D0-A316-00AA00688B10} 1.0
;typelib MSFlexGridLib {5E9E78A0-531B-11CF-91F6-C2863C385E30} 1.0

typelib MSDataGridLib {CDE57A40-8B86-11D0-B3C6-00A0C90AEA82} 1.0


if(hDlg) goto messages
if(!ShowDialog("msdatagrid_dialog" &msdatagrid_dialog)) ret

;BEGIN DIALOG
;0 "" 0x10CF0A44 0x100 0 0 421 313 "datagrid"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;4 ActiveX 0x54000000 0x0 12 4 248 101 "MSDataGridLib.DataGrid"
;END DIALOG
;DIALOG EDITOR: "" 0x2020002 "" ""


ret
;messages
sel message
,case WM_INITDIALOG
,Database db4.Open(db4.CsAccess("C:\Programme\Microsoft Visual Studio\MyProjects\vbFlexdata-example\mydatabase2.mdb"))
,ADO.Recordset rs4; ARRAY(str) a4
,db4.QueryRs("SELECT * FROM friends" rs4)
,db4.RsGetAll(rs4 a4)
,
,MSDataGridLib.DataGrid da4._getcontrol(id(4 hDlg))
,da4.AllowUpdate="True"

,da4.DataSource=+rs4

,DT_Init(hDlg lParam)
,ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,;case WM_DROPFILES mes _s
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
,,
,,
ret 1

second question:
how to fill a datalist with custom values (not recordset) ?
do you recommend another component (code will be compiled as exe).

thanks.
pi
#2
i think it's in this line.

4 ActiveX 0x54000000 0x0 12 4 248 101 "MSDataGridLib.DataGrid"

i think the 248 is the width; just make it bigger...maybe.
A new blog on QM coding and automation.

The Macro Hook
#3
Use this before populating

Code:
Copy      Help
,da4.RowHeight=100*26
,da4.DefColWidth=200*26

or this after
Code:
Copy      Help
,da4.Columns.Item(column_index).Width=200*26

I don't know what is the measurement unit. Tried to use twips (pixels*15) but it is too small. Pixels*26 is OK.
#4
Cannot answer to other questions. Tried rs4._create, but says it must be opened. Tried to add rows using AddNew but it succeeds only for first column. The same error pops up if I try to edit cells manually.
#5
... because data type was incorrect.

When recordset is opened from database (like in your code), to add new data can be used this:

Code:
Copy      Help
,int i
,for(i 0 5)
,,rs4.AddNew()
,,rs4.Fields.Item(0).Value="string"
,,rs4.Fields.Item(1).Value=i
,,rs4.Fields.Item(2).Value="string"

To set current row, use Move, MoveFirst, etc.
#6
for some strange reason my installed version of MSDATGRD.OCX
caused the size problem (6.01.9782).
with the version from my vsstudio 6 cd it is correct ( 6.0.81.69).
pi
#7
i try to use DataFormat in the datagrid, because some columns show prices.

da4.Columns.Item(1).DataFormat
qm says 'expecting IDataFormatDisp'. :?:

in my vb6 test project its:

Code:
Copy      Help
BeginProperty Column01
         DataField       =   "EK"
         Caption         =   "EK"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
            Type            =   1
            Format          =   """€"" #.##0,00"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1031
            SubFormatType   =   2
         EndProperty
      EndProperty


2. regarding datasource
i found this thread ->Using DataGrid Without DataSet (unbound)

Quote:A DataGrid's DataSource will accept any object which implements
IEnumerable (such as an Array or ArrayList), so a simple array of your
objects would be the simplest. Map columns to the properties you want
displayed.

what is the DataSet the poster in posting #3 is writing about.

thanks a lot (like ever)
.
pi
#8
Code:
Copy      Help
,typelib StdFormat {6B263850-900B-11D0-9484-00A0C91110ED} 1.0
,StdFormat.StdDataFormat fm._create
,fm.Type=StdFormat.fmtCustom
,fm.Format="''€'' #.##0,00"
,;VARIANT v; v="Yess"; fm.TrueValue=&v ;;some properties require variable
,da4.Columns.Item(1).DataFormat=+fm
#9
Quote:what is the DataSet the poster in posting #3 is writing about.

Don't know. Also don't know what is IEnumerable.


Forum Jump:


Users browsing this thread: 1 Guest(s)