简体   繁体   English

c#devexpress gridview行收集

[英]c# devexpress gridview row collect

c# devexpress gridview selected row count error i want to get row from anouther form(gridcontrol), i tryed form.gridview.selected.row.count but its not working. c#devexpress gridview选定的行计数错误我想从另一个表单(gridcontrol)获取行,我尝试了form.gridview.selected.row.count但它不起作用。 what can i write for the get this count? 我能为这个写些什么? and from other forms of money, i want to print labels to collect this form. 从其他形式的钱,我想打印标签来收集这种形式。 "" “”

gridView1.Columns["money"].SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            gridView1.Columns["money"].SummaryItem.DisplayFormat = "Toplam:{0:n2}";
            gridView1.OptionsView.ShowFooter = true;

"" i tryed this code its working but on the gridview but i want to write other form in the label. “”我尝试了此代码的工作原理,但是在gridview上,但是我想在标签中写其他形式。

form1 have gridView1. form1具有gridView1。

form2 have label2. form2具有label2。 label2 display Sum from gridView1. label2显示来自gridView1的总和。

form1 must has form2 as its field or property. form1必须具有form2作为其字段或属性。

form2 must has method public void SetSum(money sum) to set sum for label2. form2必须具有方法public void SetSum(money sum)来设置label2的总和。

Every count sum (eg by click button) call form2.SetSum(sum) 每个计数总和(例如通过单击按钮)调用form2.SetSum(sum)

MainForm.cs - Hosts form1 and form2 MainForm.cs-托管form1和form2

public partial class MainForm : Form
{
    private Form1 _form1;

    private Form2 _form2;

    public MainForm()
    {
        InitializeComponent();
        _form2 = new Form2();
        _form1 = new Form1(_form2);
    }

    private void btnForm1_Click(object sender, EventArgs e)
    {
        _form1.Show(this);
    }

    private void btnForm2_Click(object sender, EventArgs e)
    {
        _form2.Show(this);
    }
}

Form1.cs Form1.cs的

public partial class Form1 : Form
{
    private Form2 _receivedForm;

    public Form1()
    {
        InitializeComponent();
    }

    public Form1(Form2 receivedForm) : this()
    {
        _receivedForm = receivedForm;
    }

    private void btnSend_Click(object sender, EventArgs e)
    {
        _receivedForm.SetSum(txtSum.Text);
    }
}

Form2.cs: Form2.cs:

public partial class Form2 : Form
{
    public Form2()
    {
        InitializeComponent();
    }

    public void SetSum(string sum)
    {
        lblSum.Text = sum;
    }
}

在此处输入图片说明 Hope this help. 希望能有所帮助。 :D :d

ı did with this code now is working. 我使用此代码所做的工作现在可以使用。 thanks for all answer 谢谢你的回答

DataBaseDataContext db = new DataBaseDataContext();
       var sum = (from ord in db.safes select ord.money).Sum();
                lbl_safein.Text = sum.ToString();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM