⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formmain.cs

📁 windows mobile 开发实例wi ndows mobile 开发实例
💻 CS
📖 第 1 页 / 共 2 页
字号:
         // lblDatumEvent
         // 
         this.lblDatumEvent.Size = new System.Drawing.Size(168, 20);
         // 
         // dgridProjects
         // 
         this.dgridProjects.Location = new System.Drawing.Point(0, 152);
         this.dgridProjects.Size = new System.Drawing.Size(240, 96);
         this.dgridProjects.CurrentCellChanged += new System.EventHandler(this.dgridProjects_CurrentCellChanged);
         this.dgridProjects.MouseMove += new System.Windows.Forms.MouseEventHandler(this.dgridProjects_MouseMove);
         // 
         // FormMain
         // 
         this.Controls.Add(this.dgridProjects);
         this.Controls.Add(this.panelChoice);
         this.Controls.Add(this.panelBindingData);
         this.Menu = this.mainMenu1;
         this.Text = "Binding Info";
         this.Load += new System.EventHandler(this.FormMain_Load);

      }
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>

		static void Main() 
		{
			Application.Run(new FormMain());
		}

      private void FormMain_Load(object sender, EventArgs e)
      {
         YaoDurant.Data.UtilData utilData = new UtilData();
         YaoDurant.GUI.UtilGUI utilGUI = new UtilGUI();

         //  Make the Project table the DataSource.
         //  Make the strIdent field of the currently
         //     select row the Text property of the DataGrid
         //     control.
         dgridProjects.DataSource = utilData.GetProjectsDT();
         dgridProjects.DataBindings.Clear();
         dgridProjects.DataBindings.Add(
                              "Text", 
                              dgridProjects.DataSource, 
                              "strIdent");

         //  Use a utility routine to style the 
         //     layout of Projects in the DataGrid.
         UtilGUI.AddCustomDataTableStyle(dgridProjects, 
                                         "Projects");
      }

      private void dgridProjects_MouseMove(object sender, 
                                           MouseEventArgs e)
      {
         //  if the user is not interested in
         //      this event, do not handle it.
         if (! optMouseOver.Checked ) 
         {
            return;
         }

         //  Tell the user what information they are seeing.
         lblDatumEvent.Text = "Cell Under Mouse";

         //  Store the DataGrid object for early binding.
         DataGrid dgridSender = (DataGrid)sender;

         //  Store the DataGrid's DataSource object
         DataTable dtabDataSource = 
            (DataTable)dgridSender.DataSource;

         //  Use the DataSource name to retrieve
         //      and store the current TableStyle.
         DataGridTableStyle dgtsCurrent = 
            dgridSender.TableStyles[dtabDataSource.TableName];

         //  Use the DataGrid's HitTest method to get the 
         //     HitTest object for this Click.
         DataGrid.HitTestInfo httstInfo;
         httstInfo = dgridSender.HitTest(e.X, e.Y);

         //  Clear the labels that are meaningful only
         //     if the mouse is over a data cell.
         lblDatumName.Text = string.Empty;
         lblDatumValue.Text = string.Empty;
         lblDatumDataType.Text = string.Empty;

         //  Display HitTest properties in the labels
         lblDatumType.Text = httstInfo.Type.ToString();
         lblDatumRow.Text = httstInfo.Row.ToString();
         lblDatumColumn.Text = httstInfo.Column.ToString();

         //  if the mouse is positioned over a data column...
         if (httstInfo.Column != -1 ) 
         {
            //  Obtain the DataSource's column name from
            //     the ColumnStyles collection of the
            //     current TableStyle.
            string  strColumnName = 
               dgtsCurrent.GridColumnStyles[httstInfo.Column].
                  MappingName;
            lblDatumName.Text = strColumnName;

            //  Obtain the DataSource's column's data type.
            lblDatumDataType.Text = 
               dtabDataSource.Rows[0][strColumnName].
                  GetType().ToString();

            //  if ( the mouse is positioned over a data cell...
            if (httstInfo.Row != -1 ) 
            {
               //           ETHER

               //  Obtain and display the cell value from
               //     the underlying data source object.
               lblDatumValue.Text = 
                  dtabDataSource.Rows[httstInfo.Row]
                                     [strColumnName].ToString();

               //              OR

               //  Obtain and display the cell value from
               //     the DataGrid itself.
               lblDatumValue.Text = 
                  dgridSender[httstInfo.Row, 
                              httstInfo.Column].ToString();
            }
         }
      }

      private void dgridProjects_CurrentCellChanged(
                                             object sender, 
                                             EventArgs e)
      {
         //  if the user is not interested in
         //      this event, do not handle it.
         if (! optCellSelection.Checked ) 
         {
            return;
         }

         //  Tell the user what information they are seeing.
         lblDatumEvent.Text = "Current Cell";

         //  Store the DataGrid object for early binding.
         DataGrid dgridSender = (DataGrid)sender;

         //  Store the DataGrid's DataSource object
         DataTable dtabDataSource = 
            (DataTable)dgridSender.DataSource;

         //  Use the DataSource name to retrieve
         //      and store the current TableStyle.
         DataGridTableStyle dgtsCurrent = 
            dgridSender.TableStyles[dtabDataSource.TableName];

         DataGridCell cellCurr = dgridSender.CurrentCell;

         //  Display CurrentCell properties in the labels
         lblDatumType.Text = "1";
         lblDatumRow.Text = cellCurr.RowNumber.ToString();
         lblDatumColumn.Text = cellCurr.ColumnNumber.ToString();

         //  Obtain the DataSource's column name from
         //     the ColumnStyles collection of the
         //     current TableStyle.
         string  strColumnName = 
            dgtsCurrent.GridColumnStyles[cellCurr.ColumnNumber].
               MappingName;
         lblDatumName.Text = strColumnName;

         //  Obtain the DataSource's column's data type.
         lblDatumDataType.Text = 
            dtabDataSource.Rows[0][strColumnName].
               GetType().ToString();

         //           ETHER

         //  Obtain and display the cell value from
         //     the underlying data source object.
         lblDatumValue.Text = 
            dtabDataSource.Rows[cellCurr.RowNumber]
                               [strColumnName].ToString();

         //              OR

         //  Obtain and display the cell value from
         //     the DataGrid itself.
         lblDatumValue.Text = 
            dgridSender[cellCurr.RowNumber,
                        cellCurr.ColumnNumber].ToString();

         //  Display the primary key of the row; based on
         //     the DataBindings entry that was added 
         //     during the Load event.
         lblDatumKey.Text = dgridSender.Text;
      }

      private void optAny_CheckedChanged(object sender, 
                                         EventArgs e)
      {
         //  Clear the Labels
         this.lblDatumEvent.Text = string.Empty;
         this.lblDatumType.Text = string.Empty;
         this.lblDatumRow.Text = string.Empty;
         this.lblDatumColumn.Text = string.Empty;
         this.lblDatumName.Text = string.Empty;
         this.lblDatumValue.Text = string.Empty;
         this.lblDatumKey.Text = string.Empty;
         this.lblDatumDataType.Text = string.Empty;
         this.lblHdrKey.Visible = optCellSelection.Checked;
      }
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -