Sunday 5 July 2009

Legacy C#

System.Winforms (.NET 1.0) is now System.Windows.Forms. WinForms is key to knowing C#. C# 2.0 and beyond is a different beast to C# 1.0,1.1 so quite a leap is needed in terms of learning/adjusting to the new object model.

DataGrid --> DataGridView (DG -> DGV)

DGV has a new way of doing TableStyles. In the old datagrid, to hide a column we could just access the column width hierarchically, via the TableStyles and ColumnStyles properties e.g. grid.TableStyles[0].GridColumnStyles["myfield"].Width = 0 however the DGV has no concept of TableStyles. Features are directly exposed on the DGV control, the relevant one here being HeaderDefaultCellStyle. Read more on "styling a DGV" here. DGV is easier in a way, we can just to dgv.Columns[ColName].Visible=false.

ContextMenu --> ContextMenuStrip (CM->CMS)

CMS is typically displayed when user right-clicks a control. Many visible controls have a Control.ContextMenuStrip property. CMS can be shared between multiple controls. The principle is the same for CM as for CMS.

No comments: