RE: Different datatype in different rows
- From: Paul S <pas@xxxxxxxxxxxxxxxx>
- Date: Wed, 12 Sep 2007 05:30:01 -0700
Hi Linda
In which eventhandler would you do it - I tried the RowsAdded but I've seen
that the first couple of rows added are empty although there are no empty
rows in the datatable I assign to the datasource.
Can you point me to any samples showing how to restrict the input in a cell
of type double. I tried to set the Format="N2" but that wasn't enough.
Thanks
Paul S
--
Paul S
"Linda Liu [MSFT]" wrote:
Hi Paul,.
You can use a DataGridViewTextBoxColumn to contain data of different type
in your practice.
You could set the ValueType property of each cell under this column to the
corresponding type after you assign a value to the Value property of the
cell.
The following is a sample. The dataGridView1 only contains a
DataGridViewTextBoxColumn.
this.dataGridView1.RowCount = 3;
this.dataGridView1.Rows[0].Cells[0].Value = "1";
this.dataGridView1.Rows[0].Cells[0].ValueType = typeof(string);
this.dataGridView1.Rows[1].Cells[0].Value = 2;
this.dataGridView1.Rows[1].Cells[0].ValueType = typeof(int);
this.dataGridView1.Rows[2].Cells[0].Value = DateTime.Now;
this.dataGridView1.Rows[2].Cells[0].ValueType = typeof(DateTime);
Hope this helps.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
- Follow-Ups:
- RE: Different datatype in different rows
- From: Linda Liu [MSFT]
- RE: Different datatype in different rows
- References:
- RE: Different datatype in different rows
- From: Linda Liu [MSFT]
- RE: Different datatype in different rows
- Prev by Date: Question on IDesignerHost System.Windows.Forms.Form and System.Windows.Window (WPF )
- Next by Date: Composite UserControl Not serializing all properties
- Previous by thread: RE: Different datatype in different rows
- Next by thread: RE: Different datatype in different rows
- Index(es):
Relevant Pages
|