| | | 
StrataFrame Beginner
       
Group: StrataFrame Users Last Login: 10/30/2008 12:11:21 PM Posts: 11, Visits: 49 |
| | I have included some source code below which demonstrates what I'm attempting to do. I have derived my own ListView control from the StrataFrame base ListView control. I am attempting to dynamically build my column headers from the business object. All of the data is populating in the business object without a hitch, but I'm having problems with getting the column headers to display properly. (I learned most of what I'm doing from watching what StrataFrame creates in the form designer when I enter columns manually, etc.) Any ideas where I might be going wrong? public virtual void FillRows(MicroFour.StrataFrame.Business.BusinessLayer bo, string dataRetrievalMethodToExecute){ // set initial propertiesbase.SuspendLayout();base.ListPopulating += new MicroFour.StrataFrame.UI.Windows.Forms.ListView.ListPopulatingEventHandler(OnListPopulating);base.RowPopulating += new MicroFour.StrataFrame.UI.Windows.Forms.ListView.RowPopulatingEventHandler(OnRowPopulating);base.AutoColumnSort = true;base.AutoNavigateToSelectedRecord = true;base.FullRowSelect = true;base.GridLines = true;base.View = View.Details;// set up the business objectbase.BusinessObject = bo;// set up columns automaticallyMicroFour.StrataFrame.UI. ListViewPopulationColumn OHRLVPopCol;int i = 0;string[] displayFields = bo.AllFieldsList.ToArray();foreach (string field in displayFields){ base.Columns.Add(new ColumnHeader());OHRLVPopCol = new MicroFour.StrataFrame.UI.ListViewPopulationColumn();OHRLVPopCol.FormatString = "{" + i++ + "}";OHRLVPopCol.PopulationType = MicroFour.StrataFrame.UI. ListViewColumnPopulationType.FormattedString;OHRLVPopSettings.FormatColumns.Add(OHRLVPopCol); } OHRLVPopSettings.DisplayFieldNames.AddRange(displayFields); OHRLVPopSettings.BusinessObjectType = bo.GetType().ToString(); OHRLVPopSettings.DropDownFormatString = "";OHRLVPopSettings.FormatString = "{0}";OHRLVPopSettings.MethodToExecute = dataRetrievalMethodToExecute + ";";OHRLVPopSettings.ValueMember = bo.PrimaryKeyField; base.PopulationDataSourceSettings = OHRLVPopSettings;// fill the list view with x number of records base.Requery();base.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);base.ResumeLayout();// select the first element in the list viewif (Items.Count > 0)Items[0].Selected = true;} |
| | | | 
StrataFrame Beginner
       
Group: StrataFrame Users Last Login: 10/30/2008 12:11:21 PM Posts: 11, Visits: 49 |
| I figured this out. Instead of doing base.Columns.Add(new ColumnHeader()); within my loop, I am now doing base.Columns.Insert(i, displayFields[i]); and my column headers are appearing exactly as I want them to. |
| |
|
|