已更换计数的消息框 [英] Message Box for the replaced count

查看:55
本文介绍了已更换计数的消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在DataGridView中有一个名为Find and Replace的任务 - 它已经完成。但是我想要在消息框中替换计数。



任何人都可以帮我解决这个问题吗?以下是我的查找和替换代码:



Hi,

I have a task called Find and Replace in the DataGridView - It's completed.But i want the replaced count in the message box.

Can anyone help me how to achieve this? Below is my Find and Replace code:

private void btnFindandReplace_Click(object sender, EventArgs e)
        {
            f.cmbColumnCombo.DataSource = cmbList;
            f.ShowDialog();

                        if (recNo > 0)
                            recNo = recNo - 30;
                        LoadPage(MyFOrmat, true);
}
 public void LoadPage(string Format, bool isFindAndReplace = false)
        {
            int startRec;
            int endRec;

            if (currentPage == PageCount)
            {
                endRec = (int)maxRec;
            }
            else
            {
                endRec = (int)pageSize * currentPage;
            }

            dataGridView1.Rows.Clear();
            if (recNo == 0)
            {
                dataGridView1.Columns.Clear();
            }

            int rowindex = 0;
            startRec = recNo;
            for (int RowCount = startRec; RowCount <= endRec; RowCount++)
            {
                if (datfile[RowCount].ToString() != "" )
                {
                    if (RowCount == 0)
                    {
                        string[] column = datfile[RowCount].Split('þ');
                        for (int i = 0; i < column.Length - 1; i++)
                        {
                            if (column[i].ToString() != "") //if (column[i].ToString() != "" && column[i].ToString() != "\u0014")
                            {
                                DataGridViewTextBoxColumn dgvtxtcountry = new DataGridViewTextBoxColumn();
                                dgvtxtcountry.HeaderText = column[i].ToString();
                                dgvtxtcountry.Name = column[i].ToString();
                                dataGridView1.Columns.Add(dgvtxtcountry);
                                cmbList.Add(column[i]);
                                // dataGridView1.Columns["Sent Date"].DefaultCellStyle.Format = "dd/MM/yyyy";
                                i += 1;
                            }
                        }
                    }

                    if (RowCount != 0)
                    {
                        dataGridView1.Rows.Add();
                        string[] column = datfile[RowCount].Split('þ');
                        int index = 0;
                        for (int i = 1; i < column.Length - 1; i++)
                        {
                            if (column[i].ToString() != "\u0014")
                            {
                                //if (i == 3)
                                //{
                                //    dataGridView1.Rows[rowindex].Cells[index].Value = Convert.ToDateTime(column[i]).ToString(Format);
                                //}
                                //else
                                //{ 
                                    dataGridView1.Rows[rowindex].Cells[index].Value = column[i].Trim('þ'); 
                                //}

                                if (StaticVar.FnR == true && index == StaticVar.colindx)
                                {

                                    if ((column[i]).Contains(StaticVar.Find) != null)
                                        dataGridView1.Rows[rowindex].Cells[index].Value = column[i].Replace(StaticVar.Find, StaticVar.Replace);
                                }
                                if (StaticVar.DateFormat != "" && StaticVar.DateFormat != null)
                                {
                                    if (StaticVar.datecolidx == ((i - 1) / 2))
                                    {
                                        dataGridView1.Rows[rowindex].Cells[index].Value = Convert.ToDateTime(column[i]).ToString(StaticVar.DateFormat);
                                    }
                                }
                                
                                index += 1;
                                i += 1;
                            }
                        }
                        rowindex += 1;
                    }
                }
                recNo += 1;
                //IsDateFormatted = false;
            }
        }

推荐答案

我通过这种方式得到它:

if(isFindAndReplace)

{

MessageBox.Show(string.Format(No:替换值为:{0},替换));

}
I got it by this way:
if (isFindAndReplace)
{
MessageBox.Show(string.Format("No: of values replaced is: {0}", replaced));
}


这篇关于已更换计数的消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆