示例#1
0
        void objetoGrid_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if ((e.ColumnIndex == 5 || e.ColumnIndex == 8) && e.RowIndex > -1)
                {
                    DataGridViewColumn campo = ((DataGridView)sender).Columns[((DataGridView)sender).Columns[e.ColumnIndex].Tag.ToString()] as DataGridViewTextBoxColumn;
                    if (campo == null)
                    {
                        campo = ((DataGridView)sender).Columns[((DataGridView)sender).Columns[e.ColumnIndex].Tag.ToString()] as DataGridViewImageColumn;
                    }

                    campo.DataGridView.CurrentCell = campo.DataGridView.CurrentRow.Cells[campo.Index];
                    if (campo.DataGridView.CurrentRow.Index == campo.DataGridView.NewRowIndex)
                    {
                        campo.DataGridView.EndEdit();
                    }
                    if (!campo.DataGridView.IsCurrentCellDirty)
                    {
                        campo.DataGridView.NotifyCurrentCellDirty(true);
                    }
                    else
                    {
                        campo.DataGridView.NotifyCurrentCellDirty(false);
                    }

                    object objeto = null;

                    if (e.ColumnIndex == 5)
                    {
                        objeto = BuscarListaPr.BuscarBarrio();
                        if (objeto != null)
                        {
                            objeto = BarrioPr.Instancia.RegistroPorId((int)objeto);
                        }
                    }
                    else if (e.ColumnIndex == 8)
                    {
                        objeto = BuscarListaPr.BuscarPersona();
                    }

                    if (objeto != null)
                    {
                        campo.DataGridView.NotifyCurrentCellDirty(false);
                        campo.DataGridView.BeginEdit(false);
                        campo.DataGridView.CurrentRow.Cells[campo.Name].Value = objeto;
                        campo.DataGridView.EndEdit();
                    }
                    else
                    {
                        campo.DataGridView.EndEdit();
                    }
                }
            }
            catch (Exception ex)
            {
                General.Mensaje(ex.Message.ToString());
            }
        }
示例#2
0
        void colIdentificacion_ButtonCustomClick(object sender, EventArgs e)
        {
            DataGridViewTextBoxColumn campo = (DataGridViewTextBoxColumn)sender;
            object objeto = BuscarListaPr.BuscarPersona();

            if (objeto != null)
            {
                campo.DataGridView.BeginEdit(true);
                campo.DataGridView.CurrentRow.Cells["colPersona"].Value = (persona)objeto;
                campo.DataGridView.EndEdit();
            }
        }
示例#3
0
        void colIdentificacion_ButtonDropDownClick(object sender, System.ComponentModel.CancelEventArgs e)
        {
            DataGridViewTextBoxColumn campo = (DataGridViewTextBoxColumn)sender;

            campo.DataGridView.BeginEdit(false);
            if (!campo.DataGridView.IsCurrentCellDirty)
            {
                campo.DataGridView.NotifyCurrentCellDirty(true);
            }
            object objeto = BuscarListaPr.BuscarPersona();

            if (objeto != null)
            {
                campo.DataGridView.NotifyCurrentCellDirty(false);
                campo.DataGridView.CurrentRow.Cells["colPersona"].Value = (persona)objeto;
                campo.DataGridView.EndEdit();
            }
        }
示例#4
0
 void objetoGrid_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.ColumnIndex == 2 && e.RowIndex > -1)
         {
             DataGridViewTextBoxColumn campo = (DataGridViewTextBoxColumn)((DataGridView)sender).Columns[((DataGridView)sender).Columns[e.ColumnIndex].Tag.ToString()];
             campo.DataGridView.CurrentCell = campo.DataGridView.CurrentRow.Cells[campo.Index];
             if (campo.DataGridView.CurrentRow.Index == campo.DataGridView.NewRowIndex)
             {
                 campo.DataGridView.EndEdit();
             }
             if (!campo.DataGridView.IsCurrentCellDirty)
             {
                 campo.DataGridView.NotifyCurrentCellDirty(true);
             }
             else
             {
                 campo.DataGridView.NotifyCurrentCellDirty(false);
             }
             object objeto = BuscarListaPr.BuscarPersona();
             if (objeto != null)
             {
                 campo.DataGridView.NotifyCurrentCellDirty(false);
                 campo.DataGridView.BeginEdit(false);
                 campo.DataGridView.CurrentRow.Cells["colPersona"].Value = (persona)objeto;
                 campo.DataGridView.EndEdit();
             }
             else
             {
                 campo.DataGridView.EndEdit();
             }
         }
     }
     catch (Exception ex)
     {
         General.Mensaje(ex.Message.ToString());
     }
 }