4

ここに画像の説明を入力してください

セルが空かどうかを確認してメッ​​セージを保存し、すべてのメッセージを含むすべての行に新しいセルを作成する必要があります

しかし、DevExpressの操作方法がわからないので、誰かが私のコードを手伝ってくれる?

    string Name = "First Name";
    string FName = "Father Name";
    string LName = "Last Name";
    string EmpCode = "Employee Code";
    string Tax = "Tax#";
    string SocSec = "Soc.Sec#";
    string EmpType = "Employment Type";
    string DepCode = "Department Code";
    string DepDesc = "Department Description";
    private void simpleButton1_Click(object sender, System.EventArgs e)
    {
        try
        {
            OleDbConnection con = new OleDbConnection();
            con.ConnectionString = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=C:\\Users\\pc\\Documents\\Emp.xlsx;Extended Properties=\"Excel 12.0;HDR=Yes\"";

            con.Open();
            DataTable dtSchema;
            dtSchema = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
            OleDbCommand Command = new OleDbCommand ("select * FROM [" + dtSchema.Rows[0]["TABLE_NAME"].ToString() + "]", con);
            OleDbDataAdapter da = new OleDbDataAdapter(Command);
            DataSet ds = new DataSet ();
            da.Fill(ds);
            dataGrid1.DataSource = ds.Tables[0];
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

このループは、空のセルについての正しいメッセージを私に与えていません。私が書いたものは正しくないと思います。別のより良い方法があるかもしれません...

        for (int rows = 0 ; rows < gridView3.RowCount ; rows ++)
        {
            string[] msg = new string[50];

            if ((gridView3.GetRowCellValue(rows, gridView3.Columns["LName"])) == null)
            {
                msg[rows] = "name missing";
            }
        }
4

4 に答える 4

1

私が知っていることから、セルの値はnullにはなりません。ただし、基になるデータソースの値はnullになります。

セルのデータがnullであるか、nullから合計されているかを確認するには:

private bool IsNullValue(PivotDrillDownDataSource ds, PivotGridField field)
{
    if (ds.RowCount == 0 || field == null) return false;
    for (int i = 0; i < ds.RowCount; i++)
    {
        if (Equals(ds[i][field], null))
        return true;
    }
    return false;
 } 

nullセルのテキストを変更するには:

if (IsNullValue(e.CreateDrillDownDataSource(), e.DataField))
     e.DisplayText = "NULL OR SUM WITH NULL";
于 2013-01-29T08:50:01.263 に答える
1

私は同じ問題を抱えていましたが、以下のコードは私にとっては問題なく機能しましたが、OPが試したものからわずかに変更されました。それが誰かに役立つことを願っています。

for (int rows = 0 ; rows < gridView3.RowCount ; rows ++)
    {
        string[] msg = new string[50];

        if ((gridView3.GetRowCellValue(rows, "LName")) == null)
        {
            msg[rows] = "name missing";
        }
    }

LNameは文字列fieldNameに置き換える必要があります。

于 2017-01-31T12:40:04.867 に答える
0
private void gridViewPro_RowStyle(object sender, 
    DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
{
    GridView View = sender as GridView;
    if (e.RowHandle >= 0)
    {
        double Sale = Convert.ToDouble(
            View.GetRowCellDisplayText(e.RowHandle, View.Columns["PRO_S3M"]));
        double Qua = Convert.ToDouble(
            View.GetRowCellDisplayText(e.RowHandle, View.Columns["PRO_QTY"]));
        if (Sale > 0 && Qua > 0)
        {
            if (Sale >= Qua)
            {
                e.Appearance.BackColor = Color.OrangeRed;
            }
        }
    }
}
于 2014-02-18T09:49:03.663 に答える
-1

AspxGridViewのこのイベントを使用する

 protected void grid_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e)
{        // Get Cell Values here and compare as per your conditions
    string text = e.CellValue.ToString();                   
 }
于 2013-01-28T10:17:31.793 に答える