Coding guide

Common tasks side by side for the desktop (VB.NET, C#) and web (TypeScript) editions. Both editions share concepts and names.

Basics

Topic Rule
Row/column numbers Zero-based (first row = 0, first column = 0). Columns can be addressed by number or by name ("colName", name on the web)
Formula addresses One-based like Excel (A1 = first row, first column). The header row is not part of the address
Undo User actions are recorded automatically. Group several code changes so they undo in one step
Bulk work Suspend painting (BeginUpdate) and turn off undo recording (AllowUndo) while loading
Value types Numbers: Decimal/Double on the desktop, number on the web. Dates: Date. Formula errors: NoxFormulaError (desktop), FormulaError (web)

1. Set and read values

NoxGrid1(0, "colName") = "Emma Hall"
Dim name = NoxGrid1(0, "colName")
NoxGrid1.SetText(0, "colQty", "1,234")       ' text → column type (FormatException if it cannot be converted)
Dim text = NoxGrid1.GetText(0, "colQty")      ' text as displayed
NoxGrid1.SetValues(0, 0, New Object(,) {{"a", 1}, {"b", 2}})

2. Load a lot of data

NoxGrid1.BeginUpdate()
NoxGrid1.AllowUndo = False
Try
    NoxGrid1.RowCount = rows.Count
    NoxGrid1.SetValues(0, 0, data)
Finally
    NoxGrid1.AllowUndo = True
    NoxGrid1.EndUpdate()
End Try
' or bound: NoxGrid1.DataSource = dataTable

3. Formatting

With NoxGrid1.Cells(0, "colName")
    .BackColor = Color.Gold : .Bold = True : .Italic = True
End With
NoxGrid1.Cells(0, 0, 2, 3).BackColor = Color.AliceBlue    ' range
NoxGrid1.Cells(5, 0, 5, 4).Merge()
NoxGrid1.Rows(3).Height = 40
NoxGrid1.ColorScheme = NoxGridColorScheme.Modern

4. Sort, filter, find

NoxGrid1.Sort(New NoxGridColumn() {colDept, colAge}, New NoxSortOrder() {NoxSortOrder.Ascending, NoxSortOrder.Descending})
NoxGrid1.AllowFiltering = True
NoxGrid1.SetFilter(colDept, {"Internal", "Surgery"})
NoxGrid1.SetFilter(colQty, Function(v) CDec(v) >= 100)
NoxGrid1.FindNext("Emma")
NoxGrid1.ReplaceAll("Surgery", "General surgery", Nothing)   ' Nothing = default options

5. Formulas

NoxGrid1.SetFormula(10, "colAmount", "=SUM(D1:D10)")
Dim total = NoxGrid1(10, "colAmount")             ' calculated value
NoxGrid1.AllowUserFormulas = True                  ' users can type =…
NoxFormula.RegisterFunction("VAT", Function(a) Convert.ToDouble(a(0)) * 0.1)

6. Validation and conditional formatting

colQty.MinimumValue = "0" : colQty.MaximumValue = "100"
colCode.Required = True
NoxGrid1.ConditionalFormats.Add("colQty", NoxConditionOperator.GreaterThan, "100", Color.MistyRose).Bold = True
Dim errors = NoxGrid1.Validate()                 ' check before saving

7. Events

Private Sub NoxGrid1_CellValueChanged(sender As Object, e As NoxGridCellEventArgs) Handles NoxGrid1.CellValueChanged
    lblStatus.Text = $"Row {e.RowIndex + 1} changed"
End Sub

8. Group undo steps

NoxGrid1.BeginUndoAction("Add row")
NoxGrid1.Rows.Insert(0, "new row")
NoxGrid1.Cells(0, 0).BackColor = Color.Yellow
NoxGrid1.EndUndoAction()

9. Excel and printing

NoxGrid1.ImportFromExcel("source.xlsx")
NoxGrid1.ExportToExcel("result.xlsx")
NoxGrid1.PrintSettings.Title = "Lab results"
NoxGrid1.PrintPreview()

Common pitfalls

Symptom Cause / fix
The web grid is not visible The host element has no height → style="height:500px" or give it a height with flex
A formula shows #REF! A referenced row, column or sheet was deleted. Formula addresses are one-based and do not count the header row
NoxGrid is missing from the toolbox Build first, and reference Nox.Grid.Design.dll. After a version change, remove the toolbox item and add it again
Bulk loading is slow BeginUpdate/EndUpdate, AllowUndo = False, and pause your value-changed handlers
Codes with leading zeros become numbers Use a text column. Excel/CSV import keeps "00123" as text
Dates show as serial numbers Use a date column (kind: 'date', NoxGridDateColumn) or a format such as yyyy-MM-dd
The grid UI text is Korean Desktop: Korean when the Windows display language or regional format is Korean; force it with NoxGridText.Language = NoxGridLanguage.English. Web: locale: 'en' or setLocale('en')