1/3/12
DataGrid Control for Visual Basic 6.0 Users
DataGrid Control for Visual Basic 6.0 Users
Visual Studio 2005 The DataGrid con ol in Vi al Ba ic 6.0 i eplaced b he Windo Fo m Da aG idVie con ol in Vi al Ba ic 2005. The name of ome p ope ie , me hod , e en , and con an a e diffe en , and in ome ca e he e a e diffe ence in beha io .
Conceptual Differences
Data Binding
The Vi al Ba ic 2005 DataGridView con ol doe no need da a- pecific me hod o e en beca e all ac ion a e pe fo med h o gh he da a o ce. Beca e of hi epa a ion of p e en a ion and da a f nc ionali , he da a o ce can be changed i h o i ho e in e face inp . Al o, m l iple con ol bo nd o he ame da a o ce ill al a a in nc.
Navigation
P ope ie fo ie ing and na iga ion in he DataGrid con ol ( ch a TabAction, EnterAction, AllowArrows, WrapCellPointer, and Scrollable) a e no longe needed. Fo e ample, he g id f nc ion a ho gh he Scrollable p ope i e o True: If mo e da a e i han can be di pla ed, a c oll ba appea a oma icall . E celle na iga ion h o gh he g id i he defa l , allo ing he e o mo e fo a d i h he TAB ke and back a d i h he SHIFT+TAB ke combina ion. Fo mo e info ma ion, ee Defa l Ke boa d and Mo e Handling in he Windo Fo m Da aG idVie Con ol.
Caption Propert
In Vi al Ba ic 6.0, he Caption p ope i ed o di pla Caption p ope i lef emp , no i le ba i di pla ed. The Vi al Ba ic 2005 DataGridView con ol doe no achie e he ame effec ing a Label con ol. a i le ba abo e he g id; if he a i le ba . Ho e e , o can
ppo
Data Formatting
In Vi al Ba ic 6.0, fo ma ing da a in he DataGrid con ol i handled ing he DataFormat p ope and a StdDataFormat objec . Fo ma ing i applied on a col mn-b -col mn ba i . In he Vi al Ba ic 2005 DataGridView con ol, fo ma ing i accompli hed ing he Fo ma p ope of a Da aG idVie CellS le objec . Fo ma ing can be applied o indi id al cell , col mn , o o . Fo mo e info ma ion, ee Da a Fo ma ing in he Windo Fo m Da aG idVie Con ol.
hWndEditor Propert
In Vi al Ba ic 6.0, he hWndEditor p ope i DataGrid con ol' edi ing indo o a Windo ed o pa API call. he indo handle a igned o a
The Vi al Ba ic 2005 DataGridView con ol doe no ha e a epa a e indo handle hen in edi mode; in ead, e he Handle p ope of he DataGridView con ol o an embedded edi con ol .
MarqueeSt le Propert
In Vi al Ba ic 6.0, he MarqueeSt le p ope con ol he appea ance of a elec ed cell o o b changing he bo de le, in e ing he fo eg o nd and backg o nd colo , o in oking an edi indo .
[Link]/en-us/librar / 4ddh1ac(v=vs.80).asp 1/10
1/3/12
DataGrid Control for Visual Basic 6.0 Users
The e i di ec e i a e f he Vi a Ba ic 2005 DataGridVie c . H e e , ca achie e he a e effec h gh a c bi a i f he Se ec i M de, Ce B de S e, a d Format e ie . F e i f a i , ee Se ec i M de i he Wi d F Da aG idVie C .
SelLength, SelStart, SelTe t Properties
I he Vi a Ba ic 6.0 DataGrid c a d SelTe t e ie ca be ed f he e i he ce . , he a ce e e he i i ia e edi de, he SelLength, SelStart, i i f he ca e high igh a i
I he Vi a Ba ic 2005 DataGridVie c , he e e ie ge e i . The ce i he DataGridVie c a e ba ed he Te B c ; b addi g c de he Edi i gC Sh i g e e ha d e ca acce he Se ec i Le g h, Se ec i S a , a d Se ec edTe e ie f he de i g c .
Split Vie s
The Vi a Ba ic 6.0 DataGrid c a i ie , a i g he e di da a ide-b - ide. The Split bjec a d he Split, Splits, a d TabAcrossSplits he abi i di a a i ie . I he Vi a Ba ic 2005 DataGridVie c , he e e ie achie e he a e effec i g e e S i C ai e c c . T d ica e he f c i a i f he TabAcrossSplits S a da dTab e f he DataGridVie c . a he a e e ie c ca
ge e i . H e e , a d i e DataGridVie e , ca e he
Code Changes for the DataGrid Control
The f i g c de de a e he diffe e ce be ee Vi a Ba ic 6.0 a d Vi a Ba ic 2005 b h i g h , i each e i , high igh he e i a ce he a e e ec he ce i a DataGridVie c .
'Vsa Bsc60 iul ai . PiaeSbDtGi1Cik) rvt u aard_lc( DtGi1Sltr [Link] 1 DtGi1Slegh DtGi1Tx [Link] [Link] Mgo(Teslce tx i "&DtGi1Slet sBx"h eetd et s [Link]) EdSb n u
VB 'Vsa Bsc20 iul ai 05 PiaeSbDtGiVe1EiigotoSoig _ rvt u aardiw_dtnCnrlhwn( BVlsne A Ojc,BVleA [Link]._ ya edr s bet ya s ytmWnosFrs DtGiVeEiigotoSoigvnAg)_ aardiwdtnCnrlhwnEetrs HnlsDtGiVe1EiigotoSoig ade [Link] CyeeCnrl [Link] 0 Tp(.oto, eto)Slcintr CyeeCnrl [Link] Tp(.oto, eto)Slcinegh LnCyeeCnrl _ e(Tp(.oto, [Link] eto)Tx) Mgo(Teslce tx i "&CyeeCnrl _ sBx"h eetd et s Tp(.oto, [Link] eto)SlceTx) EdSb n u
[Link]/en-us/librar / 4ddh1ac(v=vs.80).asp
2/10
1/3/12
DataGrid Control for Visual Basic 6.0 Users
DataGrid Control Propert , Method, and Event Equivalencies
T B 2005 V . T . A V B B . T V B 2005, . W . 6.0 , 2005 , , , S , .W .F V
Properties Vi al Ba ic 6.0
AddNewMode
Vi al Ba ic 2005 Eq i alen
N , C . A N (BindingSource) ; , F D R U E T R G V C D . K M H . F W . D D . F G V
Align AllowAddNew AllowArrows
D A N
AllowDelete AllowRowSi ing AllowUpdate Appearance
A A A N P N
(BindingSource) R
(BindingSource) . F B . D D , 6.0 U . . F G V A B S
ApproxCount
, C BackColor B . C
Note
C C B V B V B 6.0 U 2005. F . ,
Bookmark Caption
N N
. Y . U Label
. .
3/10
[Link]/en-us/librar / 4ddh1ac(v=vs.80).asp
1/3/12
DataGrid Control for Visual Basic 6.0 Users
Col ColumnHeaders Container
Selec edCol mn Col mnHeade Vi ible Pa en ; inhe i ed f om Control. en CellDi en Cell , I C en CellInEdi Mode
CurrentCellModified I C CurrentCellVisible C
No e
If he CurrentCell p ope i e o a cell ha i no i ible, he g id c oll o ho ha cell ( imila o e ing CurrentCellVisible = True).
DataChanged DataFormats
IsCurrentCellDirt , I C
en Ro Di
DataGridViewCellSt [Link] .
No e
Fo ma ing can be e fo an indi id al cell, col mn, o o .
DefColWidth DragIcon DragMode EditActive FirstRow Font FontBold FontItalic FontName FontSi e FontStrikethrough FontUnderline ForeColor
Wid h DataGridViewColumn objec . Ne implemen a ion. Fo mo e info ma ion, ee D ag and D op fo Vi Ba ic 6.0 U e . al
IsCurrentCellInEditMode Fi Fon Di pla edSc ollingRo Inde
No e
Fon a e handled diffe en l in Vi al Ba ic 2005. Fo mo e info ma ion, ee Fon Handling fo Vi al Ba ic 6.0 U e .
Fo eColo
No e
[Link]/en-us/librar / 4ddh1ac(v=vs.80).asp 4/10
1/3/12
DataGrid Control for Visual Basic 6.0 Users
C a e ha d ed diffe e i Vi a Ba ic 2005. F ee C Beha i f Vi a Ba ic 6.0 U e .
e i f
a i
HeadFont
DataGridVie CellSt le
bjec .
No e
F a e ha d ed diffe e i Vi a Ba ic 2005. F ee F Objec f Vi a Ba ic 6.0 U e . e i f a i ,
HeadLines
N di ec e i a e . U e he W a M de e DataGridVie CellSt le bjec i c bi a i Heigh , i he i ed f Control c a .
f he i hC
Heade Heigh .
Height
No e
C i f di a e a e ha d ed diffe e i Vi a Ba ic 2005. F a i , ee C di a e S e f Vi a Ba ic 6.0 U e . e
HelpConte tID
Ne i e e a i Ba ic 6.0 U e . Handle Ne i e e a i
. F
e i f
a i
, ee He
Vi
hWnd hWndEditor Inde
. U e Handle. . F e i f a i , ee C A a f Vi a
Ne i e e a i Ba ic 6.0 U e . Lef , i he i ed f
Left
Control c a
No e
C i f di a e a e ha d ed diffe e i Vi a Ba ic 2005. F a i , ee C di a e S e f Vi a Ba ic 6.0 U e . e
LeftCol MarqueeSt le
Fi
Di
a edSc
i gC
I de
N di ec e Format R
i a e . U e he SelectionMode, CellBorderSt le, a d e ie .
RecordSelectors Ro
Heade Vi ib e
Se ec edR
5/10
[Link]/en-us/librar / 4ddh1ac(v=vs.80).asp
1/3/12
DataGrid Control for Visual Basic 6.0 Users
Ro Di ide S
le
GridColor, CellBo de S le, RowHeadersBorderSt le, ColumnHeadersBorderSt le properties. Height New implementation. You can now directl access an item. SelectedCells, Selec edCol mn
Ro Heigh SelBookma k SelEndCol SelS a Col SelLeng h
No direct equivalent. Use the Selec ionLeng h propert Edi ingCon olSho ing event handler. No direct equivalent. Use the Selec ionS a Edi ingCon olSho ing event handler. No direct equivalent. Use the Selec edTe Edi ingCon olSho ing event handler. propert
in the
SelS a
in the
SelTe
propert
in the
Spli Spli TabAc o TabAc ion Tag Te Spli
New implementation. Split views are not directl supported; use a Spli Con aine control.
S anda dTab New implementation. C en [Link] e
No e
The Val e propert returns an Objec ; use CS convert it to a S ing. or ToS ing to
ToolTipTe
ToolTip component For more information, see ToolTip Support for Visual Basic 6.0 Users.
Top
Top
No e
Coordinates are handled differentl in Visual Basic 2005. For more information, see Coordinate S stem for Visual Basic 6.0 Users.
Vi ibleCol
Di pla edCol mnCo n method.
6/10
[Link]/en-us/librar / 4ddh1ac(v=vs.80).asp
1/3/12
DataGrid Control for Visual Basic 6.0 Users
No e
In Vi al Ba ic 6.0, pa iall i ible col mn a e al a incl ded in he co n ; he Displa edColumnCount me hod e a Boolean includePartialColumns pa ame e o de e mine he he pa iall i ible col mn a e incl ded.
VisibleRo s
Displa edRo Count me hod.
No e
In Vi al Ba ic 6.0, pa iall i ible o a e al a incl ded in he co n ; he Displa edRo Count me hod e a Boolean includePartialRo s pa ame e o de e mine he he pa iall i ible o a e incl ded.
WhatsThisHelpID
Ne implemen a ion. Fo mo e info ma ion, ee Help S ppo Ba ic 6.0 U e . Wid h, inhe i ed f om Control cla .
fo Vi
al
Width
No e
Coo dina e a e handled diffe en l in Vi al Ba ic 2005. Fo mo e info ma ion, ee Coo dina e S em fo Vi al Ba ic 6.0 U e .
WrapCellPointer
No longe an adj True.
able p ope
; defa l beha io i WrapCellPointer =
Me hod Vi al Ba ic 6.0
CaptureImage
Vi al Ba ic 2005 Eq i alen
Ne implemen a ion. Cap PictureBo con ol i no Ne ing he con en ppo ed. of a DataGridVie con ol o a
ClearFields ClearSelCols ColContaining Drag
implemen a ion. Col mn fo ma ing i a
oma ic
hen e-binding.
Clea Selec ion Inde Of (DataGridVie ColumnCollection) Ne implemen a ion. Fo mo e info ma ion, ee D ag and D op fo Vi 6.0 U e .. Ne implemen a ion. Bookma k a e no longe ppo ed.
7/10
al Ba ic
GetBookmark
[Link]/en-us/librar / 4ddh1ac(v=vs.80).asp
1/3/12
DataGrid Control for Visual Basic 6.0 Users
HoldField Mo e
Ne
implemen a ion. Col mn fo ma ing i p e e .
ed
hen ebinding.
Se Bo nd , inhe i ed f om Con ol cla
Note
Coo dina e a e handled diffe en l in Vi al Ba ic 2005. Fo mo e info ma ion, eeCoo dina e S em fo Vi al Ba ic 6.0 U e .
Rebind Ro Bookma k Ro Con aining Ro Top Sc oll Se Foc Sho Wha Thi
Re e Binding , inhe i ed f om Con ol cla Ne
. ppo ed.
implemen a ion. Bookma k a e no longe
Inde Of (Da aG idVie Col mnCollec ion) Ge Con en Bo nd (Da aG idVie Cell) Ne Foc Ne implemen a ion. Fo mo e info ma ion, ee Help S ppo U e . ie a e no di ec l ppo ed; fo Vi al Ba ic 6.0 implemen a ion me hod. U e he C en Cell p ope .
Spli Con aining Ne implemen a ion. Spli Spli Con aine con ol. ZO de
e a
B ingToF on ()o SendToBack()f nc ion
E ents Vi al Ba ic 6.0
Af e ColEdi Af e ColUpda e Af e Dele e Af e Upda e Befo eColEdi Befo eColUpda e Befo eDele e Befo eIn e Befo eUpda e
[Link]/en-us/librar / 4ddh1ac(v=vs.80).asp 8/10
Vi al Ba ic 2005 Eq i alen
CellEndEdi Ne implemen a ion. Da a ope a ion a e handled in he da a o ce. Fo mo e info ma ion, ee Di pla ing Da a in he Windo Fo m Da aG idVie Con ol. Ro Added
CellBeginEdi Ne implemen a ion. Da a ope a ion a e handled in he da a o ce. Fo mo e info ma ion, ee Di pla ing Da a in he Windo Fo m Da aG idVie Con ol.
1/3/12
DataGrid Control for Visual Basic 6.0 Users
ButtonClick Change
Click (Button con ol) Te Changed
No e
The beha io of he TextChanged e en i ligh l diffe en . Fo mo e info ma ion, ee ComboBo Con ol Change E en fo Vi al Ba ic 6.0 U e .
Click ColEdit ColResi e DblClick DragDrop DragOver Error HeadClick MouseDown MouseMove MouseUp
Selec edInde Changed CellBeginEdit Col mnWid hChanged CellMo eDo bleClick al Ba ic
Ne implemen a ion. Fo mo e info ma ion, ee D ag and D op fo Vi 6.0 U e .
Da aE o Col mnHeade Mo CellMo CellMo CellMo eDo n eMo e eUp al Ba ic eClick
OLECompleteDrag Ne implemen a ion. Fo mo e info ma ion, ee D ag and D op fo Vi 6.0 U e . OLEDragDrop OLEDragOver OLEGiveFeedback OLESetData OLEStartDrag
OnAddNew RowColChange
RowsAdded C en CellChanged
9/10
[Link]/en-us/librar / 4ddh1ac(v=vs.80).asp
1/3/12
DataGrid Control for Visual Basic 6.0 Users
RowResi e SelChange SplitChange
RowHeightChanged SelectionChanged New implementation. Split views are not directly supported; use a SplitContainer control. Validating
Validate
Upgrade Notes
When a Visual Basic 6.0 project is upgraded to Visual Basic 2005, the Change event of the DataGrid control is mapped to the TextChanged event of the Visual Basic 2005 DataGridView control. The behavior of the TextChanged event differs from that of the Change event; this difference may cause unintended results in your code. Any code related to data-specific methods or events is not upgraded. Warning comments are added to the code, and the code must be removed or modified before compiling the application.
See Also
Reference DataGridView Control Overview (Windows Forms) Controls and Programmable Objects Compared in Different Languages and Libraries Concepts DataGridView Control Technology Summary (Windows Forms) What's New in Windows Forms and Windows Forms Controls Other Resources DataGridView Control (Windows Forms) Windows Forms Controls for Visual Basic 6.0 Users Windows Forms Data Binding
Communit Content
2012 Microsoft. All rights reserved.
[Link]/en-us/librar / 4ddh1ac(v=vs.80).asp
10/10