当前位置: 首页>>代码示例>>C#>>正文


C# DataGridView.Refresh方法代码示例

本文整理汇总了C#中System.Windows.Forms.DataGridView.Refresh方法的典型用法代码示例。如果您正苦于以下问题:C# DataGridView.Refresh方法的具体用法?C# DataGridView.Refresh怎么用?C# DataGridView.Refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.DataGridView的用法示例。


在下文中一共展示了DataGridView.Refresh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Pesquisar

        public void Pesquisar(DataGridView dg)
        {
            RelatorioControl rControl = new RelatorioControl();
            BindingSource pesquisa = new BindingSource();

            pesquisa.DataSource = rControl.GetRelatorios();
            dg.DataSource = pesquisa;

            if (pesquisa.Count <= 0) //trata o caso q a busca é vazia.
            {
                return;
            }

            //popula o datagrid retornado
            dg.RowsDefaultCellStyle.BackColor = Color.White;
            dg.AlternatingRowsDefaultCellStyle.BackColor = Color.AliceBlue;
            dg.EnableHeadersVisualStyles = true;

            //formata as colunas do datagrid
            dg.Columns["Id"].HeaderText = "Rel. nº"; //Nome coluna
            dg.Columns["Id"].Width = 78; //largura coluna
            dg.Columns["Id"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            dg.Columns["Id"].ToolTipText = "Número do Relatório";
            dg.Columns["Id"].DefaultCellStyle.Format = "0000000";
            dg.Columns["Id"].Visible = true;

            dg.Columns["Descricao"].HeaderText = "Descrição"; //Nome coluna
            dg.Columns["Descricao"].Width = 597; //largura coluna
            dg.Columns["Descricao"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            dg.Columns["Descricao"].ToolTipText = "Descrição do Relatório";
            dg.Columns["Descricao"].Visible = true;

            dg.Refresh();
        }
开发者ID:fsbflavio,项目名称:SPCP,代码行数:34,代码来源:frmRelatorio.cs

示例2: DatesAvailableBox

        public DataGridView DatesAvailableBox(DataGridView data, Member selectedMember)
        {
            data.Rows.Clear();
            data.Refresh();
            data.Columns["Date"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            List<UnavailableDate> udates = manager.UnavailableDateByMemberId(selectedMember.Id);
            TimeSpan startSpan = new TimeSpan(21, 0, 0, 0);
            TimeSpan endSpan = new TimeSpan(120, 0, 0, 0);
            DateTime start = DateTime.Now - startSpan;
            DateTime end = DateTime.Now + endSpan;
            string dayOfWeekMeeting = selectedMember.Congregation.WeekMeetingDay;
            string dayOfPublicMeeting = selectedMember.Congregation.PublicMeetingDay;
            bool available = true;
            foreach (DateTime day in manager.EachDayLoop(start, end))
            {
                available = true;
                if (udates.Any(z => z.DateUnavailable == day) ||
                    (selectedMember.IsAvailablePublicMeeting == false && day.DayOfWeek.ToString() == dayOfPublicMeeting) ||
                    (selectedMember.IsAvailableWeekMeeting == false && day.DayOfWeek.ToString() == dayOfWeekMeeting))
                {
                    available = false;
                }
                if (Convert.ToString(day.DayOfWeek) == dayOfWeekMeeting || Convert.ToString(day.DayOfWeek) == dayOfPublicMeeting)
                {
                    string dd = day.DayOfWeek + ", " + day.ToShortDateString();
                    data.Rows.Add(null, available, dd);
                }

            }

            return data;
        }
开发者ID:inguscrowe,项目名称:MeetingManager,代码行数:32,代码来源:CommonControls.cs

示例3: SetRowsVisibilityByScore

 public static void SetRowsVisibilityByScore(DataGridView gridView, double threshold, bool visState)
 {
     Console.WriteLine("Hiding");
     gridView.SuspendLayout();
     CurrencyManager currencyManager = gridView.BindingContext[gridView.DataSource] as CurrencyManager;
     currencyManager.SuspendBinding();
     int timeElapsed = Environment.TickCount;
     foreach(DataGridViewRow row in gridView.Rows)
     {
         int timeTick = Environment.TickCount;
         Console.WriteLine("Toggling row {0} - {1}", row, timeTick - timeElapsed);
         timeElapsed = timeTick;
         try
         {
             double ms2Score = (double)row.Cells.GetCellValueFromColumnHeader("MS2 Score");
             if (ms2Score < threshold)
             {
                 row.Visible = visState;
             }
         }
         catch
         {
             Console.WriteLine(row);
             //row.Visible = false;
         }
     }
     currencyManager.ResumeBinding();
     gridView.ResumeLayout();
     gridView.Refresh();
 }
开发者ID:GlycReSoft2,项目名称:GlycReSoftTandemGlycopeptidePipeline,代码行数:30,代码来源:GridViewHelper.cs

示例4: CurrentMembersBox

        public DataGridView CurrentMembersBox(DataGridView data, int congregationId)
        {
            List<Member> mem = manager.MembersByCongregationId(congregationId);
            data.Rows.Clear();
            data.Refresh();
            data.AutoGenerateColumns = false;
            data.ColumnCount = 2;
            data.Columns[0].Name = "Id";
            data.Columns[0].Visible = false;
            data.Columns[1].Name = "Member";
            data.Columns[1].Visible = true;
            data.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            foreach (Member m in mem)
            {
                string[] row = new string[2];
                if (m.PreferredName == null || m.PreferredName == "")
                {
                    row = new string[2] { m.Id.ToString(), m.FirstName + " " + m.LastName };
                }
                else
                {
                    row = new string[2] { m.Id.ToString(), Convert.ToString(m.PreferredName) };
                }

                data.Rows.Add(row);
            }

            return data;
        }
开发者ID:inguscrowe,项目名称:MeetingManager,代码行数:29,代码来源:CommonControls.cs

示例5: CreateTab

 private void CreateTab(SharpMap.Data.FeatureDataTable featureDataTable)
 {
   this.tabControl1.TabPages.Add(featureDataTable.TableName, featureDataTable.TableName);
   System.Windows.Forms.DataGridView dv = new DataGridView();
   dv.AllowUserToAddRows = false;
   dv.AllowUserToDeleteRows = false;
   dv.AllowUserToOrderColumns = true;
   dv.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
   dv.Font = this.Font;
   dv.DataBindingComplete += new DataGridViewBindingCompleteEventHandler(dv_DataBindingComplete);
   dv.Dock = System.Windows.Forms.DockStyle.Fill;
   dv.Location = new System.Drawing.Point(3, 3);
   dv.Name = "dvSelection";
   dv.ReadOnly = true;
   dv.Size = new System.Drawing.Size(278, 234);
   dv.TabIndex = 1;
   dv.VirtualMode = true;
   dv.CellValueNeeded += new DataGridViewCellValueEventHandler(dv_CellValueNeeded);
   dv.CellDoubleClick += new DataGridViewCellEventHandler(dv_CellDoubleClick);
   dv.CellClick += new DataGridViewCellEventHandler(dv_CellClick);
   dv.AllowUserToAddRows = false;
   dv.AllowUserToDeleteRows = false;
   dv.AllowUserToOrderColumns = true;
   dv.AllowUserToResizeColumns = true;
   dv.AllowUserToResizeRows = true;
   dv.MultiSelect = false;
   this.tabControl1.TabPages[featureDataTable.TableName].Controls.Add(dv);
   //dv.DataSource = featureDataTable;
   DataSources[featureDataTable.TableName] = featureDataTable;
   SetupRowsAndColumns(dv, featureDataTable);
   dv.Refresh();
 }
开发者ID:diegowald,项目名称:intellitrack,代码行数:32,代码来源:ElementInformation.cs

示例6: SetupDataGridView

 private DataGridView SetupDataGridView()
 {
     var dg = new DataGridView();
     ComicList = new BindingList<ComicLineItem>();
     ComicList.Add(new ComicLineItem(){ ComicName = "Test" });
     dg.DataSource = ComicList;
     dg.Refresh();
     return dg;
 }
开发者ID:taladon,项目名称:Comics-Organizer,代码行数:9,代码来源:ComicVM.cs

示例7: CalcularPrecioHabitaciones

        private void CalcularPrecioHabitaciones(DataGridView dataGridView)
        {
            foreach (Habitacion habitacion in (List<Habitacion>)dataGridView.DataSource)
            {
                habitacion.cantidadPersonas = RepositorioHabitacion.Instance.CantidadPersonasParaHabitacion(habitacion);

                habitacion.precio = (/*((Regimen)this.RegimenDataGrid.CurrentRow.DataBoundItem).precio*/ 
                    (this.RegimenParaCalculo()).precio * 
                                    habitacion.cantidadPersonas) + ((Hotel)hotelComboBox.SelectedItem).recarga;
            }
            dataGridView.Refresh();
        }
开发者ID:cthaeh,项目名称:NINIRODIE-HOTEL,代码行数:12,代码来源:ModificarReserva.cs

示例8: Delete

        public void Delete(DataGridView ddv)
        {
            int indexid = 0;
            indexid = ddv.CurrentRow.Index;
            string sql = "";
            sql = "delete from T_CustomerInf where CustID='" + ddv.Rows[indexid].Cells[0].Value.ToString() + "'";
            try
            {
                (new SqlDBConnect()).ExecuteNonQuery(sql);
                //ddv.Rows.RemoveAt(ddv.CurrentRow.Index);
                ddv.Refresh();
            }
            catch { MessageBox.Show("数据更新失败或存在外码约束!"); }

            finally
            {
            }
        }
开发者ID:TGHGH,项目名称:Warehouse-2,代码行数:18,代码来源:CustomerDAO.cs

示例9: ConfiguraDataGridView

        public static void ConfiguraDataGridView(DataGridView dg, string nome)
        {
            DataTable dt = new DataTable();
            ItemEstoqueControl itemEstoque = new ItemEstoqueControl();
            dt = itemEstoque.Pesquisar(nome);

            //popula o datagrid retornado
            dg.RowsDefaultCellStyle.BackColor = Color.White;
            dg.AlternatingRowsDefaultCellStyle.BackColor = Color.AliceBlue;
            dg.EnableHeadersVisualStyles = true;
            dg.DataSource = dt;

            //formata as colunas do datagrid
            dg.Columns["ID_ITEM"].HeaderText = "Reg. nº"; //Nome coluna
            dg.Columns["ID_ITEM"].Width = 80; //largura coluna
            dg.Columns["ID_ITEM"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            dg.Columns["ID_ITEM"].ToolTipText = "Número do Registro";
            dg.Columns["ID_ITEM"].DefaultCellStyle.Format = "0000000";
            dg.Columns["ID_ITEM"].Visible = true;

            dg.Columns["DESCRICAO"].HeaderText = "Descrição"; //Nome coluna
            dg.Columns["DESCRICAO"].Width = 300; //largura coluna
            dg.Columns["DESCRICAO"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            dg.Columns["DESCRICAO"].ToolTipText = "Descrição";
            dg.Columns["DESCRICAO"].Visible = true;

            dg.Columns["UNIDADE_MEDIDA"].HeaderText = "Unidade de Medida"; //Nome coluna
            dg.Columns["UNIDADE_MEDIDA"].Width = 150; //largura coluna
            dg.Columns["UNIDADE_MEDIDA"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            dg.Columns["UNIDADE_MEDIDA"].ToolTipText = "Unidade de Medida";
            dg.Columns["UNIDADE_MEDIDA"].Visible = true;

            dg.Columns["ESTOQUE_MINIMO"].HeaderText = "Estoque Minimo"; //Nome coluna
            dg.Columns["ESTOQUE_MINIMO"].Width = 150; //largura coluna
            dg.Columns["ESTOQUE_MINIMO"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft;
            dg.Columns["ESTOQUE_MINIMO"].ToolTipText = "Estoque Minimo";
            dg.Columns["ESTOQUE_MINIMO"].Visible = true;

            dg.Refresh();

            //-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
            return;
        }
开发者ID:fsbflavio,项目名称:SPCP,代码行数:43,代码来源:frmItemEstoque-old.cs

示例10: Delete

        public void Delete(DataGridView ddv)
        {
            SqlDBConnect sqldb = new SqlDBConnect();
            int indexid = 0;
            indexid = ddv.CurrentRow.Index;
            string sql = "";
            sql = "delete from T_CustomerCall where BargId='" + ddv.Rows[indexid].Cells["合同编号"].Value.ToString() + "'";
            try
            {
                sqldb.ExecuteNonQuery(sql);
                //MessageBox.Show("数据更新成功!");
                ddv.Rows.RemoveAt(ddv.CurrentRow.Index);
                ddv.Refresh();
            }
            catch { MessageBox.Show("数据更新失败或存在外码约束!"); }

            finally
            {
            }
        }
开发者ID:TGHGH,项目名称:Warehouse-2,代码行数:20,代码来源:CustomerCallDAO.cs

示例11: ConvertDg2Bmp

        public static void ConvertDg2Bmp(
            DataGridView dg,
            string sFilePath)
        {
            dg.Refresh();
            dg.Select();

            Graphics g = dg.CreateGraphics();
            var ibitMap = new Bitmap
                (
                dg.ClientSize.Width,
                dg.ClientSize.Height,
                g);
            Graphics iBitMapGr = Graphics.FromImage(ibitMap);
            IntPtr iBitMapHdc = iBitMapGr.GetHdc();
            IntPtr meHdc = g.GetHdc();

            BitBlt
                (
                    iBitMapHdc,
                    0,
                    0,
                    dg.ClientSize.Width,
                    dg.ClientSize.Height,
                    meHdc,
                    0,
                    0,
                    Src);
            g.ReleaseHdc(meHdc);
            iBitMapGr.ReleaseHdc(iBitMapHdc);

            if (sFilePath == "")
            {
                return;
            }
            ibitMap.Save
                (
                    sFilePath,
                    ImageFormat.Bmp);
        }
开发者ID:Brett1981,项目名称:ReuseableClasses,代码行数:40,代码来源:DataGridViewtoBitMap.cs

示例12: CopyDataGridViewPrintSelected

        public static DataGridView CopyDataGridViewPrintSelected(DataGridView source)
        {
            DataGridView copy = new DataGridView();

            try
            {
                if (copy.Columns.Count == 0)
                {
                    foreach (DataGridViewColumn column in source.Columns)
                    {
                        copy.Columns.Add(column.Clone() as DataGridViewColumn);
                    }
                }

                var row = new DataGridViewRow();

                for (int i = 0; i < source.Rows.Count; i++)
                {
                    row = (DataGridViewRow)source.Rows[i].Clone();
                    if ((bool)source.Rows[i].Cells["Print"].Value == true)
                    {
                        var columnIndex = 0;
                        foreach (DataGridViewCell cell in source.Rows[i].Cells)
                        {
                            row.Cells[columnIndex].Value = cell.Value;
                            columnIndex++;
                        }
                        copy.Rows.Add(row);
                    }
                }
                copy.Refresh();

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return copy;
        }
开发者ID:JBuchter,项目名称:UnclaimedFundsViewer,代码行数:40,代码来源:DataGridViewUtilities.cs

示例13: Delete

        public void Delete(DataGridView ddv)
        {
            SqlDBConnect sqldb = new SqlDBConnect();

            int indexid = 0;
            indexid = ddv.CurrentRow.Index;
            string sql = "";
            sql = "delete from T_CustContacts where CName='" + ddv.Rows[indexid].Cells["联系姓名"].Value.ToString().Trim () + "'";
            try
            {
                sqldb.ExecuteNonQuery(sql);
                MessageBox.Show("删除成功!");
                ddv.Rows.RemoveAt(ddv.CurrentRow.Index);
                ddv.Refresh();
            }
            catch { MessageBox.Show("更新失败!"); }

            finally
            {

            }
        }
开发者ID:TGHGH,项目名称:Warehouse-2,代码行数:22,代码来源:CustContactsDAO.cs

示例14: updateTable

        //updating a table
        public void updateTable(DataGridView dataGridView1, string selectcommand, string tableName, int maxHeight)
        {
            SqlCeDataAdapter adapter = new SqlCeDataAdapter();
            SqlCeCommand cmd = Form1.con.CreateCommand();
            DataSet ds = new DataSet();
            cmd.CommandText = selectcommand;
            adapter.SelectCommand = cmd;
            adapter.Fill(ds, tableName);
            int row = ds.Tables[tableName].Rows.Count - 1;
            int dgrow = dataGridView1.Rows.Count - 2;
            //checkign if a row was deleted
            while (dgrow >= row + 1)
            {
                dataGridView1.Rows.RemoveAt(dgrow);
                dgrow--;
            }
            //checkign if a row was added
            while (dgrow < row)
            {
                dataGridView1.Rows.Add();
                dgrow++;
            }

            //updating datas
            int cellnr = dataGridView1.Rows[0].Cells.Count;
            for (int r = 0; r <= row; r++)
            {
                for (int i = 0; i < cellnr; ++i)
                {
                    dataGridView1.Rows[r].Cells[i].Value = ds.Tables[tableName].Rows[r].ItemArray[i];
                }
            }

            //set automatic height to datagridview
            dataGridView1.Height = setAutomaticHeight(dataGridView1.Columns[0].HeaderCell.Size.Height, dataGridView1.Rows[0].Height, dataGridView1.Rows.Count, maxHeight);
            dataGridView1.Refresh();
        }
开发者ID:Ernyoke,项目名称:CarRent,代码行数:38,代码来源:ParentTab.cs

示例15: llenarDataGrid

 public static void llenarDataGrid(DataGridView dg, SqlConnection conn, SqlCommand cmd)
 {
     SqlDataAdapter da = new SqlDataAdapter();
         da.SelectCommand = cmd;
         DataTable tabla = new DataTable();
         conn.Open();
         da.Fill(tabla);
         conn.Close();
         dg.DataSource = tabla;
         dg.Refresh();
 }
开发者ID:juanmjacobs,项目名称:gestion2c2013,代码行数:11,代码来源:SQLLibrary.cs


注:本文中的System.Windows.Forms.DataGridView.Refresh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。