Esempio n. 1
0
        private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
        {
            m_pCurFeature = null;
            if (e.Button == MouseButtons.Right && e.RowIndex >= 0 && e.RowIndex <= dataGridView1.Rows.Count)
            {
                m_nCurRowIndex = e.RowIndex;
                dataGridView1.Rows[m_nCurRowIndex].Selected = true;
                //contextMenuStrip1.Show(MousePosition.X, MousePosition.Y);
                m_pCurFeature = EngineFuntions.GetOneSeartchFeature(EngineFuntions.m_Layer_BusStation, "OBJECTID = " + dataGridView1.Rows[m_nCurRowIndex].Cells["OBJECTID"].Value.ToString());
            }

            if (m_bEdit && e.Button == MouseButtons.Left && e.RowIndex >= 0 && e.RowIndex <= dataGridView1.Rows.Count)
            {
                if (e.ColumnIndex == dataGridView1.Columns["开始日期"].Index ||
                    e.ColumnIndex == dataGridView1.Columns["结束日期"].Index ||
                    e.ColumnIndex == dataGridView1.Columns["申请时间"].Index ||
                    e.ColumnIndex == dataGridView1.Columns["归档日期"].Index)
                {
                    m_Rectangle    = dataGridView1.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true); //得到所在单元格位置和大小
                    m_dtp.Size     = new Size(m_Rectangle.Width, m_Rectangle.Height);                        //把单元格大小赋给时间控件
                    m_dtp.Location = new System.Drawing.Point(m_Rectangle.X, m_Rectangle.Y);                 //把单元格位置赋给时间控件
                    m_dtp.Visible  = true;                                                                   //可以显示控件了
                }
                else
                {
                    m_dtp.Visible = false;
                }
            }
        }
Esempio n. 2
0
 private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
 {
     m_pCurFeature = null;
     if (e.Button == MouseButtons.Right && e.RowIndex >= 0 && e.RowIndex <= dataGridView1.Rows.Count)
     {
         m_nCurRowIndex = e.RowIndex;
         dataGridView1.Rows[m_nCurRowIndex].Selected = true;
         contextMenuStrip1.Show(MousePosition.X, MousePosition.Y);
         m_pCurFeature = EngineFuntions.GetOneSeartchFeature(EngineFuntions.m_Layer_BusStation, "OBJECTID = " + dataGridView1.Rows[m_nCurRowIndex].Cells["OBJECTID"].Value.ToString());
     }
 }
Esempio n. 3
0
 private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     if (m_bEdit)
     {
         m_nCurRowIndex = e.RowIndex;
         m_pCurFeature  = EngineFuntions.GetOneSeartchFeature(EngineFuntions.m_Layer_BusStation, "OBJECTID = " + dataGridView1.Rows[m_nCurRowIndex].Cells["OBJECTID"].Value.ToString());
         if (m_pCurFeature != null)
         {
             string strName = dataGridView1.Columns[e.ColumnIndex].Name;
             int    nField  = m_pCurFeature.Fields.FindField(strName);
             if (strName == "开始日期" || strName == "结束日期" || strName == "申请时间" || strName == "归档日期")
             {
                 m_pCurFeature.set_Value(nField, Convert.ToDateTime(dataGridView1.Rows[m_nCurRowIndex].Cells[e.ColumnIndex].Value));
             }
             else
             {
                 m_pCurFeature.set_Value(nField, dataGridView1.Rows[m_nCurRowIndex].Cells[e.ColumnIndex].Value);
             }
             m_pCurFeature.Store();
         }
     }
 }