예제 #1
0
 private void PopulateCell(int p_GridRow, int p_GridCol, System.Reflection.PropertyInfo p_PropInfo, SourceGrid2.DataModels.IDataModel p_DataModel, object p_Object)
 {
     if ((grid.ColumnsCount > 0) && (p_GridCol == grid.ColumnsCount - 1))
     {
         grid[p_GridRow, p_GridCol] = new Cells.Cell(ClsStaticStation.m_Global.mycls.SignalsNames[Convert.ToInt16(p_PropInfo.GetValue(p_Object, null))], p_DataModel);
         SourceGrid2.BehaviorModels.CustomEvents l_CustomEvents = new SourceGrid2.BehaviorModels.CustomEvents();
         l_CustomEvents.ValueChanged += new SourceGrid2.PositionEventHandler(Grid_ValueChanged);
         grid[p_GridRow, p_GridCol].Behaviors.Add(l_CustomEvents);
     }
     else
     {
         grid[p_GridRow, p_GridCol] = new Cells.Cell(p_PropInfo.GetValue(p_Object, null), p_DataModel);
         SourceGrid2.BehaviorModels.BindProperty l_Bind = new SourceGrid2.BehaviorModels.BindProperty(p_PropInfo, p_Object);
         grid[p_GridRow, p_GridCol].Behaviors.Add(l_Bind);
         SourceGrid2.BehaviorModels.CustomEvents l_CustomEvents = new SourceGrid2.BehaviorModels.CustomEvents();
         l_CustomEvents.ValueChanged += new SourceGrid2.PositionEventHandler(Grid_ValueChanged);
         grid[p_GridRow, p_GridCol].Behaviors.Add(l_CustomEvents);
     }
 }
예제 #2
0
        private void frmSampleGrid1_Load(object sender, System.EventArgs e)
        {
            string[] l_CountryList = new string[] { "Italy", "France", "Spain", "UK", "Argentina", "Mexico", "Switzerland", "Brazil", "Germany", "Portugal", "Sweden", "Austria" };

            grid1.RowsCount                    = 1;
            grid1.ColumnsCount                 = 10;
            grid1.FixedRows                    = 1;
            grid1.FixedColumns                 = 1;
            grid1.Selection.SelectionMode      = SourceGrid2.GridSelectionMode.Row;
            grid1.AutoStretchColumnsToFitWidth = true;
            grid1.Columns[0].AutoSizeMode      = SourceGrid2.AutoSizeMode.None;
            grid1.Columns[0].Width             = 30;

            #region Create Header Row and Editor
            Cells.Header l_00Header = new Cells.Header();
            grid1[0, 0] = l_00Header;

            m_CellEditor_Id = SourceGrid2.Utility.CreateDataModel(typeof(int));
            m_CellEditor_Id.EditableMode = SourceGrid2.EditableMode.Focus | SourceGrid2.EditableMode.AnyKey | SourceGrid2.EditableMode.SingleClick;
            grid1[0, 1] = new Cells.ColumnHeader("ID (int)");

            m_CellEditor_Name = SourceGrid2.Utility.CreateDataModel(typeof(string));
            m_CellEditor_Name.EditableMode = SourceGrid2.EditableMode.Focus | SourceGrid2.EditableMode.AnyKey | SourceGrid2.EditableMode.SingleClick;
            grid1[0, 2] = new Cells.ColumnHeader("NAME (string)");

            m_CellEditor_Address = SourceGrid2.Utility.CreateDataModel(typeof(string));
            m_CellEditor_Address.EditableMode = SourceGrid2.EditableMode.Focus | SourceGrid2.EditableMode.AnyKey | SourceGrid2.EditableMode.SingleClick;
            grid1[0, 3] = new Cells.ColumnHeader("ADDRESS (string)");

            m_CellEditor_City = SourceGrid2.Utility.CreateDataModel(typeof(string));
            m_CellEditor_City.EditableMode = SourceGrid2.EditableMode.Focus | SourceGrid2.EditableMode.AnyKey | SourceGrid2.EditableMode.SingleClick;
            grid1[0, 4] = new Cells.ColumnHeader("CITY (string)");

            m_CellEditor_BirthDay = SourceGrid2.Utility.CreateDataModel(typeof(DateTime));
            m_CellEditor_BirthDay.EditableMode = SourceGrid2.EditableMode.Focus | SourceGrid2.EditableMode.AnyKey | SourceGrid2.EditableMode.SingleClick;
            grid1[0, 5] = new Cells.ColumnHeader("BIRTHDATE (DateTime)");

            m_CellEditor_Country = new SourceGrid2.DataModels.EditorComboBox(typeof(string), l_CountryList, false);
            m_CellEditor_Country.EditableMode = SourceGrid2.EditableMode.Focus | SourceGrid2.EditableMode.AnyKey | SourceGrid2.EditableMode.SingleClick;
            grid1[0, 6] = new Cells.ColumnHeader("COUNTRY (string + combobox)");

            m_CellEditor_Price = new SourceGrid2.DataModels.EditorTextBox(typeof(double));
            m_CellEditor_Price.TypeConverter = new SourceLibrary.ComponentModel.Converter.CurrencyTypeConverter(typeof(double));
            m_CellEditor_Price.EditableMode  = SourceGrid2.EditableMode.Focus | SourceGrid2.EditableMode.AnyKey | SourceGrid2.EditableMode.SingleClick;
            grid1[0, 7] = new Cells.ColumnHeader("$ PRICE (double)");

            grid1[0, 8] = new Cells.ColumnHeader("Selected");

            grid1[0, 9] = new Cells.ColumnHeader("WebSite");
            #endregion


            #region Visual Properties
            //set Cells style
            m_VisualProperties = new SourceGrid2.VisualModels.Common(false);

            m_VisualPropertiesPrice = (SourceGrid2.VisualModels.Common)m_VisualProperties.Clone(false);
            m_VisualPropertiesPrice.TextAlignment = ContentAlignment.MiddleRight;

            m_VisualPropertiesCheckBox = (SourceGrid2.VisualModels.CheckBox)SourceGrid2.VisualModels.CheckBox.Default.Clone(false);

            m_VisualPropertiesLink = (SourceGrid2.VisualModels.Common)SourceGrid2.VisualModels.Common.LinkStyle.Clone(false);
            #endregion

            //read xml
            System.IO.StreamReader l_Reader = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("SampleProject.Samples.SampleData.xml"));
            System.Xml.XmlDocument l_XmlDoc = new System.Xml.XmlDocument();
            l_XmlDoc.LoadXml(l_Reader.ReadToEnd());
            l_Reader.Close();
            System.Xml.XmlNodeList l_Rows = l_XmlDoc.SelectNodes("//row");
            grid1.RowsCount = l_Rows.Count + 1;
            int l_RowsCount = 1;
            foreach (System.Xml.XmlNode l_Node in l_Rows)
            {
                #region Pupulate RowsCount
                grid1[l_RowsCount, 0] = new Cells.RowHeader();

                grid1[l_RowsCount, 1]             = new Cells.Cell(l_RowsCount);
                grid1[l_RowsCount, 1].DataModel   = m_CellEditor_Id;
                grid1[l_RowsCount, 1].VisualModel = m_VisualProperties;

                grid1[l_RowsCount, 2]             = new Cells.Cell(l_Node.Attributes["ContactName"].InnerText);
                grid1[l_RowsCount, 2].DataModel   = m_CellEditor_Name;
                grid1[l_RowsCount, 2].VisualModel = m_VisualProperties;

                grid1[l_RowsCount, 3]             = new Cells.Cell(l_Node.Attributes["Address"].InnerText);
                grid1[l_RowsCount, 3].DataModel   = m_CellEditor_Address;
                grid1[l_RowsCount, 3].VisualModel = m_VisualProperties;

                grid1[l_RowsCount, 4]             = new Cells.Cell(l_Node.Attributes["City"].InnerText);
                grid1[l_RowsCount, 4].DataModel   = m_CellEditor_City;
                grid1[l_RowsCount, 4].VisualModel = m_VisualProperties;

                grid1[l_RowsCount, 5]             = new Cells.Cell(DateTime.Today);
                grid1[l_RowsCount, 5].DataModel   = m_CellEditor_BirthDay;
                grid1[l_RowsCount, 5].VisualModel = m_VisualProperties;

                grid1[l_RowsCount, 6]             = new Cells.Cell(l_Node.Attributes["Country"].InnerText);
                grid1[l_RowsCount, 6].DataModel   = m_CellEditor_Country;
                grid1[l_RowsCount, 6].VisualModel = m_VisualProperties;

                grid1[l_RowsCount, 7]             = new Cells.Cell(25.0);
                grid1[l_RowsCount, 7].DataModel   = m_CellEditor_Price;
                grid1[l_RowsCount, 7].VisualModel = m_VisualPropertiesPrice;

                grid1[l_RowsCount, 8]             = new Cells.CheckBox(false);
                grid1[l_RowsCount, 8].VisualModel = m_VisualPropertiesCheckBox;

                grid1[l_RowsCount, 9]                      = new Cells.Link(l_Node.Attributes["website"].InnerText);
                grid1[l_RowsCount, 9].VisualModel          = m_VisualPropertiesLink;
                ((Cells.Link)grid1[l_RowsCount, 9]).Click += new SourceGrid2.PositionEventHandler(CellLink_Click);
                #endregion

                l_RowsCount++;
            }

            grid1.AutoSizeAll();
        }
예제 #3
0
 private void PopulateCell(int p_GridRow, int p_GridCol, System.Reflection.PropertyInfo p_PropInfo, SourceGrid2.DataModels.IDataModel p_DataModel, object p_Object)
 {
     grid[p_GridRow, p_GridCol] = new Cells.Cell(p_PropInfo.GetValue(p_Object, null), p_DataModel);
     SourceGrid2.BehaviorModels.BindProperty l_Bind = new SourceGrid2.BehaviorModels.BindProperty(p_PropInfo, p_Object);
     grid[p_GridRow, p_GridCol].Behaviors.Add(l_Bind);
     SourceGrid2.BehaviorModels.CustomEvents l_CustomEvents = new SourceGrid2.BehaviorModels.CustomEvents();
     l_CustomEvents.ValueChanged += new SourceGrid2.PositionEventHandler(Grid_ValueChanged);
     grid[p_GridRow, p_GridCol].Behaviors.Add(l_CustomEvents);
 }
예제 #4
0
 private void PopulateCell(int p_GridRow, int p_GridCol, System.Reflection.PropertyInfo p_PropInfo, SourceGrid2.DataModels.IDataModel p_DataModel, object p_Object)
 {
 }