예제 #1
0
        /// <summary>
        /// 向上查找输入的信息
        /// </summary>
        private void btnPrevious_Click(object sender, EventArgs e)
        {
            try
            {
                if (textContent.Text.Trim() == "")
                {
                    return;
                }
                int locationRowNo    = browseXtraGridView.FocusedRowHandle;
                int locationColumnNo = browseXtraGridView.FocusedColumn.AbsoluteIndex;

                textContent.Focus();
                browseXtraGridView.Focus();
                for (int i = locationRowNo; i >= 0; i--)
                {
                    for (int j = locationColumnNo - 1; j >= 0; j--)
                    {
                        if (!browseXtraGridView.Columns[j].Visible)
                        {
                            continue;
                        }
                        string cellValue = DataTypeConvert.GetString(browseXtraGridView.GetRowCellDisplayText(i, browseXtraGridView.Columns[j]));
                        if (cellValue.Contains(textContent.Text.Trim()))
                        {
                            browseXtraGridView.FocusedRowHandle = i;
                            browseXtraGridView.FocusedColumn    = browseXtraGridView.Columns[j];

                            GridViewInfo    vi       = browseXtraGridView.GetViewInfo() as GridViewInfo;
                            GridDataRowInfo rowInfo  = vi.RowsInfo.GetInfoByHandle(i) as GridDataRowInfo;
                            GridCellInfo    cellInfo = rowInfo.Cells[0];
                            if (cellInfo != null)
                            {
                                cellInfo.State = GridRowCellState.FocusedCell;
                            }
                            return;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    locationColumnNo = browseXtraGridView.Columns.Count;
                }
            }
            catch (Exception ex)
            {
                //ExceptionHandler.HandleException(this.Text + "--向上查找输入的信息错误。", ex);
                ExceptionHandler.HandleException(this.Text + "--" + f.tsmiXsczsrdxxcw.Text, ex);
            }
        }
예제 #2
0
        private void RecalcWidths(DevExpress.XtraGrid.Views.Grid.GridView view, int[] widths)
        {
            GridViewInfo info = view.GetViewInfo() as GridViewInfo;

            int       room     = info.ViewRects.ColumnPanelWidth;
            int       sumWidth = 0;
            ArrayList cols     = new ArrayList();

            foreach (GridColumn col in view.VisibleColumns)
            {
                sumWidth += widths[col.AbsoluteIndex];
                cols.Add(col);
            }
            if (sumWidth == 0)
            {
                return;
            }
            if (sumWidth > room)
            {
                return;                  //prevent extreme column squeezing
            }
            int remains = room;

            foreach (GridColumn col in cols)
            {
                col.Width = room * widths[col.AbsoluteIndex] / sumWidth;
                remains  -= col.Width;
            }
            view.VisibleColumns[view.VisibleColumns.Count - 1].Width += remains;
        }
예제 #3
0
        public Cursor GetDragCursor(int rowHandle, Point e)
        {
            GridViewInfo info        = _View.GetViewInfo() as GridViewInfo;
            GridRowInfo  rowInfo     = info.GetGridRowInfo(rowHandle);
            Rectangle    imageBounds = new Rectangle(new Point(0, 0), rowInfo.TotalBounds.Size);
            Rectangle    totalBounds = new Rectangle(new Point(0, 0), info.Bounds.Size);
            Bitmap       bitmap      = new Bitmap(totalBounds.Width, totalBounds.Height);

            //Grid
            Bitmap    gridBitmap = new Bitmap(totalBounds.Width, totalBounds.Height);
            Rectangle rectBound  = _View.GridControl.Bounds;

            rectBound.X = 0;
            rectBound.Y = 0;
            _View.GridControl.DrawToBitmap(gridBitmap, rectBound);


            DevExpress.Utils.Drawing.GraphicsCache cache = new DevExpress.Utils.Drawing.GraphicsCache(Graphics.FromImage(bitmap));

            GridViewDrawArgs args = new GridViewDrawArgs(cache, info, totalBounds);

            DrawRow(args, rowInfo);

            Bitmap   result         = new Bitmap(imageBounds.Width, imageBounds.Height);
            Graphics resultGraphics = Graphics.FromImage(result);

            float[][] matrixItems =
            {
                new float[] { 1, 0, 0,    0, 0 },
                new float[] { 0, 1, 0,    0, 0 },
                new float[] { 0, 0, 1,    0, 0 },
                new float[] { 0, 0, 0, 0.7f, 0 },
                new float[] { 0, 0, 0,    0, 1 }
            };
            ColorMatrix     colorMatrix     = new ColorMatrix(matrixItems);
            ImageAttributes imageAttributes = new ImageAttributes();

            imageAttributes.SetColorMatrix(
                colorMatrix,
                ColorMatrixFlag.Default,
                ColorAdjustType.Bitmap);
            resultGraphics.DrawImage(gridBitmap, imageBounds, rowInfo.TotalBounds.X, rowInfo.TotalBounds.Y, rowInfo.TotalBounds.Width, rowInfo.TotalBounds.Height, GraphicsUnit.Pixel, imageAttributes);
            Point offset = new Point(e.X - rowInfo.TotalBounds.X, e.Y - rowInfo.TotalBounds.Y);

            //result.Save("file" + DateTime.Now.Millisecond + ".bmp");

            return(CreateCursor(result, offset));
        }