0
我試圖驗證用戶在可編輯的gridview中輸入的內容。 我使用事件CellLeave驗證輸入,就像這樣:嘗試將gridview單元格值解析爲任何類型(驗證)
private void membersGrid_CellLeave(object sender, DataGridViewCellEventArgs e)
{
// Datatable that will hold the schema for the Members table
DataTable dtMeta;
// SqlDataAdapter is already filled and is now used to get the metadata
daAllMembers.FillSchema(dtMeta, SchemaType.Source);
// Define a type instance of the current column from the metadata table dtMeta
System.Type cellType = dtMeta.Columns[e.ColumnIndex].DataType;
// Get an object from the editted cell
Object objCellValue = membersGrid[e.ColumnIndex, e.RowIndex].Value;
// This is where i'm stuck, how can I do this?
cellType.TryParse(objCellValue);
}
我希望你明白我想要做的事。我基本上想要嘗試將該對象解析爲該表的元數據中定義的類型。
任何幫助表示讚賞;)
嘿謝謝,我會調查一下併發回給你! – DerpyNerd 2013-04-30 15:39:05