public void OpenModelList(object sender, EventArgs e) { UIButton btnModelSearch = (UIButton)sender; ScreenUtils scnUtils = new ScreenUtils (); scnUtils.GetAbsolutePosition (btnModelSearch); float iTop = scnUtils.GetPositionTop (); float iLeft = scnUtils.GetPositionLeft (); int iBtnTagId = btnModelSearch.Tag; int iPwrIdRow = iBtnTagId / iEquipmentModelSearchTagId; int iStringRow = iBtnTagId - (iPwrIdRow * iEquipmentModelSearchTagId); int iSectionCounterTagId = iEquipmentRowSectionCounterTagId * iPwrIdRow + iStringRow; UILabel hfSectionCounter = (UILabel)View.ViewWithTag (iSectionCounterTagId); int iSectionCounterId = Convert.ToInt32 (hfSectionCounter.Text); UILabel lblSupplier = (UILabel)View.ViewWithTag (iEquipmentMakeTagId * (iPwrIdRow) + (iStringRow)); string sSupplier = lblSupplier.Text; if (sSupplier == "") { iUtils.AlertBox alert = new iUtils.AlertBox (); alert.CreateErrorAlertDialog ("You must select a make before you can select a model"); return; } UILabel lblEquipmentType = (UILabel)View.ViewWithTag (iEquipmentTypeTagId * (iPwrIdRow) + (iStringRow)); int iEquipmentType = Convert.ToInt32(lblEquipmentType.Text); //Create a list and convert the string array to the list. Why the system cannot take a simple string array is beyond me!!! List<string> listModel = new List<string> (); clsTabletDB.ITPInventory ITPInventory = new clsTabletDB.ITPInventory (); string[] sModels; switch(iEquipmentType) { case 3: sModels = ITPInventory.GetRackModels (sSupplier); m_sRackModels = sModels; Array.ForEach (m_sRackModels, value => listModel.Add (value.ToString ())); break; case 4: sModels = ITPInventory.GetSubRackModels (sSupplier); m_sSubRackModels = sModels; Array.ForEach (m_sSubRackModels, value => listModel.Add (value.ToString ())); break; case 5: sModels = ITPInventory.GetPositionModels (sSupplier); m_sPositionModels = sModels; Array.ForEach (m_sPositionModels, value => listModel.Add (value.ToString ())); break; case 7: sModels = ITPInventory.GetSolarStringModels (sSupplier); m_sSolarStringModels = sModels; Array.ForEach (m_sSolarStringModels, value => listModel.Add (value.ToString ())); break; default: sModels = ITPInventory.GetPositionModels (sSupplier); m_sPositionModels = sModels; Array.ForEach (m_sPositionModels, value => listModel.Add (value.ToString ())); break; } TableViewSource tabdata = new TableViewSource (listModel, true); tabdata.SetFont("Verdana",10f); UITableView cmbModel = new UITableView (); //If the bottom of the frame would be outside the main content frame make it go upwards instead of downwards UILabel hfContentHeight = (UILabel)View.ViewWithTag (3); int iContentHeight = Convert.ToInt32 (hfContentHeight.Text); if (iTop + 190f > (float)iContentHeight) { if (iLeft + 290f > 1000f) { cmbModel.Frame = new RectangleF(iLeft - 300f, iTop - 190f, 290f, 200f); } else { cmbModel.Frame = new RectangleF(iLeft, iTop - 190f, 290f, 200f); } } else { if (iLeft + 290f > 1000f) { cmbModel.Frame = new RectangleF(iLeft - 300f, iTop, 290f, 200f); } else { cmbModel.Frame = new RectangleF(iLeft, iTop, 290f, 200f); } } tabdata.SetParent(cmbModel); tabdata.SetUpdateFieldType("UILabel"); UILabel lblVwUpdate = (UILabel)View.ViewWithTag (iEquipmentModelTagId * (iPwrIdRow) + (iStringRow)); tabdata.SetLabelViewToUpdate(lblVwUpdate); UIView vwUnsaved = (UIView)View.ViewWithTag (60); tabdata.SetUnsavedChangesView(vwUnsaved); tabdata.SetShowUnsavedOnChange(true); UILabel hfRowStatus = (UILabel)View.ViewWithTag (iEquipmentRowStatusTagId * (iPwrIdRow) + (iStringRow)); UILabel lblSPN = (UILabel)View.ViewWithTag (iEquipmentSPNHiddenTagId * (iPwrIdRow) + (iStringRow)); tabdata.SetModelPostUpdate(6, hfRowStatus, lblSPN, sSupplier); //Here the 6 refers to the post update index and NOT batteries as the equipment type //Also set the section flag to 1 that it has changed and the overall flag that it has changed UILabel lblUnsavedFlag = (UILabel)View.ViewWithTag (80); tabdata.SetUnsavedChangesHiddenLabel(lblUnsavedFlag); UIButton btnSectionSave = (UIButton)View.ViewWithTag ((iSectionCounterId + 1) * iSaveSectionBtnTagId); tabdata.SetSectionSaveButton(btnSectionSave); UILabel lblUnsavedSectionFlag = (UILabel)View.ViewWithTag ((iSectionCounterId + 1) * iSectionStatusTagId); tabdata.SetUnsavedChangesSectionHiddenLabel(lblUnsavedSectionFlag); cmbModel.Source = tabdata; iUtils.SESTable thistable = new iUtils.SESTable(); string sSelectedValue = lblVwUpdate.Text; switch(iEquipmentType) { case 3: thistable.SetTableSelectedText(cmbModel, sSelectedValue, m_sRackModels, true); break; case 4: thistable.SetTableSelectedText(cmbModel, sSelectedValue, m_sSubRackModels, true); break; case 5: thistable.SetTableSelectedText(cmbModel, sSelectedValue, m_sPositionModels, true); break; case 7: thistable.SetTableSelectedText(cmbModel, sSelectedValue, m_sSolarStringModels, true); break; default: thistable.SetTableSelectedText(cmbModel, sSelectedValue, m_sPositionModels, true); break; } //Get the main scroll view UIScrollView scrollVw = (UIScrollView)View.ViewWithTag (2); scrollVw.AddSubview(cmbModel); }