ListView Add Column


Node Information
Adds column to the specified ListView.
General Information
• This node doesn't have other available options.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Add IN RUN MULTIPLE FALSE FALSE
ListView IN ListView ONE FALSE FALSE
Text IN String ONE FALSE FALSE
Name IN String ONE FALSE FALSE
Width IN Int32 ONE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.UI.ListView
{
    [IsNode("Add Column")]
    public class ListViewAddColumn : Node
    {
        Port run = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "Add");
        Port text = new Port(PortType.IN, typeof(string), AcceptsLinks.ONE, "Text");
        Port name = new Port(PortType.IN, typeof(string), AcceptsLinks.ONE, "Name");
        Port width = new Port(PortType.IN, typeof(int), AcceptsLinks.ONE, "Width");
        Port control = new Port(PortType.IN, typeof(Korduene.Designer.Standard.ListView), AcceptsLinks.ONE, "ListView");
        public string Text
        {
            set { text.Value = value.ToString(); }
            get { return GetRuntimeValue(text); }
        }
        public ListViewAddColumn()
        {
            this.Name = "ListView Add Column";
            this.NodeType = KGraph.NodeType.Method;
            width.Value = "0";
            AddPort(run);
            AddPort(control);
            AddPort(text);
            AddPort(name);
            AddPort(width);
            Information = "Adds column to the specified ListView.";
        }
        public override string Code()
        {
            string wd = GetValue(width);
            string code = "System.Windows.Forms.ColumnHeader ch = new System.Windows.Forms.ColumnHeader();" + Environment.NewLine +
            "ch.Text = " + GetValue(text) + ";\r\n" +
            "ch.Name = " + GetValue(name) + ";\r\n" +
            "//WIDTH" + Environment.NewLine +
            GetValue(control) + ".Columns.Add(ch);";
            if (wd != "0")
            {
                code.Replace("//WIDTH", "ch.Width = " + wd + ";" + Environment.NewLine);
            }
            return code;
        }
    }
}