devexpress开发笔记

//作者: V: jbossjf 
1、gridcontrol

 this.gridView1.IndicatorWidth = 40;
            this.gridView1.OptionsView.ShowGroupPanel = false;
            this.gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;
            //gridView1.OptionsView.ColumnAutoWidth = false;
            gridView1.OptionsBehavior.Editable = false;
            gridView1.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridview_CustomDrawRowIndicator);

 private void gridview_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
        {

            if (e.Info.IsRowIndicator && e.RowHandle >= 0)

                e.Info.DisplayText = (e.RowHandle + 1).ToString();

        }
2、等待窗体
WaitDialogForm dlg;
        private void navBarItem1_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            dlg = new WaitDialogForm("正在加载请等待。。。","数据处理");           
            if (!FrmIsExist("Frm_NewOrder"))
            {
                if ((GlobalVariable.frm_BuyWziard == null) || (GlobalVariable.frm_BuyWziard.IsDisposed))
                {
                    GlobalVariable.frm_BuyWziard = new Frm_BuyWziard();
                }
                GlobalVariable.frm_BuyWziard.Show();               
            }
            dlg.Close();
        }

3、lookUpEdit1初始化
   WcfService.Core.YYJServiceReference1.Service1Client sc = new WcfService.Core.YYJServiceReference1.Service1Client();
            DataTable ShopDT = sc.GetRealShopData("jbossjf");

            this.lookUpEdit1.Properties.DataSource = ShopDT;
            this.lookUpEdit1.Properties.DisplayMember = "Name"; //绑定Text显示的字段源名称
            this.lookUpEdit1.Properties.ValueMember = "ID"; //绑定Value字段源名称
            this.lookUpEdit1.EditValue = string.Empty;
            LookUpColumnInfoCollection colCollection1 = lookUpEdit1.Properties.Columns;
            colCollection1.Clear();


            colCollection1.Add(new LookUpColumnInfo("ShopDT", "", 0));

            取ID:   this.lookUpEdit1.EditValue

4、线程
 DevExpress.Data.CurrencyDataController.DisableThreadingProblemsDetection = true;
            Control.CheckForIllegalCrossThreadCalls = false;

5、提示框
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DevExpress.XtraEditors;
using System.Windows.Forms;

namespace ZL.Shell桌面.Dialog
{
    class DialogBox
    {
        /// <summary>
        /// 显示信息
        /// </summary>
        /// <param name="strSting"></param>
        public static void Show(string strSting)
        {
            DevExpress.XtraEditors.XtraMessageBox.Show(strSting, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        /// <summary>
        /// 确定或取消
        /// </summary>
        /// <param name="strString"></param>
        /// <returns></returns>
        public static DialogResult Confirm(string strString)
        {
            return DevExpress.XtraEditors.XtraMessageBox.Show(strString, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
        }

        /// <summary>
        /// 确定删除
        /// </summary>
        /// <returns></returns>
        public static DialogResult ConfirmDelete()
        {
            return DevExpress.XtraEditors.XtraMessageBox.Show("确定要删除吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
        }

    }
}

6、界面传值
 StationXtraFormItem frm = new StationXtraFormItem(ID);
                if (frm.ShowDialog() == DialogResult.OK)
                {

                    InitData();
                    // Update();
                }

  this.DialogResult = DialogResult.OK;


7、gridcontrol双击行事件
 DataRow myDataRow = gridView1.GetDataRow(gridView1.FocusedRowHandle);
            string SOSID = myDataRow["SOSID"].ToString();
            if (SOSID.Trim().Equals(string.Empty))
            {
                DevExpress.XtraEditors.XtraMessageBox.Show("当前选择的用户没有SOS求助报警信息!", "提示");
                return;
            }
            HanldSosXtraForm frm = new HanldSosXtraForm(SOSID);
             if (frm.ShowDialog() == DialogResult.OK)
             {
                 gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["Address"], "");
                 gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["SOSID"], "");
                 gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["Status"], "正常");
             }

上一篇:11.29


下一篇:DevExpress GridView获取选中行某列的值