Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
2599 | Feb 3,2003 07:31 PM UTC | Feb 4,2003 03:35 PM UTC | WinForms | 2 |
![]() |
Tags: GridControl |
private void gridControl1_CurrentCellValidating(object sender, CancelEventArgs e) { GridCurrentCell cc = this.gridControl1.CurrentCell; if( this.gridControl1[cc.RowIndex, cc.ColIndex].CellValueType == typeof(double)) { string s = cc.Renderer.ControlText; try { double d = double.Parse(s); } catch { cc.ErrorMessage = "bad value"; e.Cancel = true; } } }3) On your cancel button, try setting its CausesValidation property to false. 4) At the grid level, you could handle CurrrentCellKeyPress.
private void gridControl1_CurrentCellKeyPress(object sender, KeyPressEventArgs e) { GridCurrentCell cc = this.gridControl1.CurrentCell; if(this.gridControl1[cc.RowIndex, cc.ColIndex].CellType == "NumericUpDown") { e.Handled = true; } }Currently, you can save CSV and TSV files. Future releases will support XLS and XML.
//save text private void button3_Click(object sender, System.EventArgs e) { this.gridControl1.Model.TextDataExchange.ExportTabDelim = ","; string outPut; int nRows, nCols; GridRangeInfoList rangeInfoList = new GridRangeInfoList(); rangeInfoList.Add(GridRangeInfo.Cells(1, 1, this.gridControl1.RowCount, this.gridControl1.ColCount)); bool b = this.gridControl1.Model.TextDataExchange.CopyTextToBuffer(out outPut, rangeInfoList, out nRows, out nCols); if(b) { StreamWriter writer = new StreamWriter("test.csv"); writer.Write(outPut); writer.Close(); } }
> private void gridControl1_CurrentCellValidating(object sender, CancelEventArgs e) > { > GridCurrentCell cc = this.gridControl1.CurrentCell; > if( this.gridControl1[cc.RowIndex, cc.ColIndex].CellValueType == typeof(double)) > { > string s = cc.Renderer.ControlText; > try > { > double d = double.Parse(s); > } > catch > { > cc.ErrorMessage = "bad value"; > e.Cancel = true; > } > } > } >> > 3) On your cancel button, try setting its CausesValidation property to false. > > 4) At the grid level, you could handle CurrrentCellKeyPress. >
> private void gridControl1_CurrentCellKeyPress(object sender, KeyPressEventArgs e) > { > GridCurrentCell cc = this.gridControl1.CurrentCell; > if(this.gridControl1[cc.RowIndex, cc.ColIndex].CellType == "NumericUpDown") > { > e.Handled = true; > } > } >> > > Currently, you can save CSV and TSV files. Future releases will support XLS and XML. > >
> //save text > private void button3_Click(object sender, System.EventArgs e) > { > this.gridControl1.Model.TextDataExchange.ExportTabDelim = ","; > > string outPut; > int nRows, nCols; > GridRangeInfoList rangeInfoList = new GridRangeInfoList(); > rangeInfoList.Add(GridRangeInfo.Cells(1, 1, this.gridControl1.RowCount, this.gridControl1.ColCount)); > bool b = this.gridControl1.Model.TextDataExchange.CopyTextToBuffer(out outPut, rangeInfoList, out nRows, out nCols); > > if(b) > { > StreamWriter writer = new StreamWriter("test.csv"); > writer.Write(outPut); > writer.Close(); > } > } >
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.