Home > Net > Whether DatagGridiView cell to an empty string or null
Whether DatagGridiView cell to an empty string or null
Time:11-01
The following code, I want to determine whether a DatagGridiView winform in cell to an empty string or null, if not all together as they are, The following 5 lines of code is too hurt, is there anyone more elegant writing?
var vendors=string. The Empty; Foreach (DataGridViewRow row in DGV. Rows) { Object vendor=row. Cells [r]. "colVendor" Value; If (vendor!=null & amp; & Vendor. The ToString ()!=string. The Empty & amp; & ! Vendors. The Contains (vendor. The ToString ())) { Vendors +=vendor. The ToString () + "; "; } }
CodePudding user response:
This judgment if (! String. IsNullOrEmpty (vendor)) {
}
CodePudding user response:
Thanks for your reply, but compiling pass, vendor is object type