RE: Different datatype in different rows

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.


.



Relevant Pages

  • Re: Request object doesnt include items that have a blank value
    ... certain form item's value is empty, the only possible cause is that there ... that particular page's control tree. ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Different datatype in different rows
    ... You can use a DataGridViewTextBoxColumn to contain data of different type ... You could set the ValueType property of each cell under this column to the ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • RE: Unable to add dialog control variables from the resource editor
    ... found that the class header and source filenames were empty and grayed out ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vc.ide_general)
  • RE: NULL DACL versis Empty DACL and Owner implcit access
    ... Empty DACL means denying any access request to anyone, ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.platformsdk.security)
  • RE: Display an empty grid
    ... You can inherit from GridView and override CreateChildControls to create ... Show Header/Footer of Gridview with Empty Data ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)