/// <summary> /// Set the row header of tableLayoutPanel /// </summary> public void SetRowHeader(TableLayoutPanel calendarPanel) { int col = 0; int maxRow = calendarPanel.RowCount < resourceList.Count + 1 ? calendarPanel.RowCount : resourceList.Count + 1; for (int row = 1; row < maxRow; row++) { ResourceLabel rscLbl = calendarPanel.GetControlFromPosition(col, row) as ResourceLabel; rscLbl.resource = resourceList[row - 1]; rscLbl.Text = rscLbl.ToString(); } }
/// <summary> /// Find out the row number correspond to a specific resource /// </summary> /// <param name="calendarPanel"></param> /// <param name="resourceID"></param> /// <returns>The row number. Null if not found</returns> private int?FindRowByResourceID(TableLayoutPanel calendarPanel, int resourceID) { for (int row = 1; row < calendarPanel.RowCount; row++) { ResourceLabel resourceLbl = (ResourceLabel)calendarPanel.GetControlFromPosition(0, row); if (resourceLbl.resource.ResourceID == resourceID) { return(row); } } return(null); }