TableDesigner.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WebForms / System / Web / UI / Design / WebControls / TableDesigner.cs / 1 / TableDesigner.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Web.UI.Design.WebControls { 
 
    using System;
    using System.Collections; 
    using System.ComponentModel;
    using Microsoft.Win32;
    using System.Diagnostics;
    using System.Web.UI.WebControls; 

    ///  
    ///  
    ///    
    ///       The designer for the  
    ///       web control.
    ///    
    /// 
    [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, Flags = System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)] 
    [SupportsPreviewControl(true)]
    public class TableDesigner : ControlDesigner { 
        public override string GetDesignTimeHtml() { 
            Table table = (Table)ViewControl;
            TableRowCollection rows = table.Rows; 
            bool emptyTable = (rows.Count == 0);
            bool emptyRows = false;

            if (emptyTable) { 
                TableRow row = new TableRow();
 
                rows.Add(row); 

                TableCell cell = new TableCell(); 

                cell.Text = "###";
                rows[0].Cells.Add(cell);
            } 
            else {
                emptyRows = true; 
                for (int i = 0; i < rows.Count; i++) { 
                    if (rows[i].Cells.Count != 0) {
                        emptyRows = false; 
                        break;
                    }
                }
 
                if (emptyRows == true) {
                    TableCell cell = new TableCell(); 
 
                    cell.Text = "###";
                    rows[0].Cells.Add(cell); 
                }
            }

            if (emptyTable == false) { 
                // rows and cells were defined by the user, but if the cells are empty
                // then something needs to be done about that, so they are visible 
                foreach (TableRow row in rows) { 
                    foreach (TableCell cell in row.Cells) {
                        if ((cell.Text.Length == 0) && (cell.HasControls() == false)) { 
                            cell.Text = "###";
                        }
                    }
                } 
            }
 
            return base.GetDesignTimeHtml(); 
        }
    } 
}


// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.


                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK