{"id":100231,"date":"2016-07-16T00:39:51","date_gmt":"2016-07-15T16:39:51","guid":{"rendered":"http:\/\/www.ilzhi.cn\/?p=100231"},"modified":"2017-05-22T22:32:33","modified_gmt":"2017-05-22T14:32:33","slug":"gridview-rowcount-%e4%b8%8e-gridview-datarowcount-%e7%9a%84%e5%8c%ba%e5%88%ab","status":"publish","type":"post","link":"http:\/\/www.ilezhi.cn\/?p=100231","title":{"rendered":"GridView.RowCount \u4e0e GridView.DataRowCount \u7684\u533a\u522b"},"content":{"rendered":"<p>RowCount<\/p>\n<blockquote><p>GridView.RowCount Property | WinForms Controls | DevExpress Help<\/p>\n<div id=\"dx-top\" class=\"dx-main\">\n<div class=\"dx-groupContent\">\n<p>This property overrides the <a href=\"DevExpressXtraGridViewsBaseBaseView_RowCounttopic.htm\">BaseView.RowCount<\/a> property to increment its value in the following cases:<\/p>\n<ul type=\"disc\">\n<li>the new item row is shown at the bottom (the View&#8217;s <a href=\"DevExpressXtraGridViewsGridGridOptionsView_NewItemRowPositiontopic.htm\">GridOptionsView.NewItemRowPosition<\/a> property is set to the <a href=\"DevExpressXtraGridViewsGridNewItemRowPositionEnumtopic.htm\">NewItemRowPosition.Bottom<\/a> value);<\/li>\n<li>the new item row is hidden (the View&#8217;s <a href=\"DevExpressXtraGridViewsGridGridOptionsView_NewItemRowPositiontopic.htm\">GridOptionsView.NewItemRowPosition<\/a> property is set to the <a href=\"DevExpressXtraGridViewsGridNewItemRowPositionEnumtopic.htm\">NewItemRowPosition.None<\/a> value) and a newly added row is being edited.<\/li>\n<\/ul>\n<div class=\"dx-notes dx-note\">\n<p><span class=\"dx-notes-title dx-note-title\">Note<\/span><a href=\"CustomDocument780.htm\">Detail pattern Views<\/a> do not contain data and they are never displayed within XtraGrid. So, the <b>RowCount<\/b> member must not be invoked for these Views. The <b>RowCount<\/b> member can only be used with real Views that are displayed within the Grid Control. The real Views with which an end-user interacts at runtime can be accessed using the following methods.<\/p>\n<ul type=\"disc\">\n<li><a href=\"DevExpressXtraGridGridControl_MainViewtopic.htm\">GridControl.MainView<\/a> &#8211; returns the top most View in a grid;<\/li>\n<li><a href=\"DevExpressXtraGridGridControl_FocusedViewtopic.htm\">GridControl.FocusedView<\/a> &#8211; returns the focused View;<\/li>\n<li><a href=\"DevExpressXtraGridGridControl_DefaultViewtopic.htm\">GridControl.DefaultView<\/a> &#8211; returns the currently maximized View;<\/li>\n<li>the <em>sender<\/em> parameter of View specific events;<\/li>\n<li><a href=\"DevExpressXtraGridViewsGridGridView_GetDetailViewtopic.htm\">GetDetailView<\/a> &#8211; returns a <a href=\"CustomDocument780.htm\">detail clone View<\/a> for a specific master row.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/blockquote>\n<p>DataRowCount<\/p>\n<blockquote><p>BaseView.DataRowCount Property | WinForms Controls | DevExpress Help<\/p>\n<div id=\"dx-top\" class=\"dx-main\">\n<div class=\"dx-groupContent\">\n<p>Note that data rows can be hidden within collapsed groups when <a href=\"CustomDocument694.htm\">data grouping<\/a> is applied. The <b>DataRowCount<\/b> property returns the total number of data rows regardless of whether they are within collapsed groups or not. Also, the property&#8217;s return value is not always the same as the number of records within the associated data source. When data filtering is applied, the <b>DataRowCount<\/b> property returns the number of rows that match the filter condition.<\/p>\n<div class=\"dx-notes dx-note\">\n<p><span class=\"dx-notes-title dx-note-title\">Note<\/span><a href=\"CustomDocument780.htm\">Detail pattern Views<\/a> do not contain data and they are never displayed within XtraGrid. So, the <b>DataRowCount<\/b> member must not be invoked for these Views. The <b>DataRowCount<\/b> member can only be used with real Views that are displayed within the Grid Control. The real Views with which an end-user interacts at runtime can be accessed using the following methods.<\/p>\n<ul type=\"disc\">\n<li><a href=\"DevExpressXtraGridGridControl_MainViewtopic.htm\">GridControl.MainView<\/a> &#8211; returns the top most View in a grid;<\/li>\n<li><a href=\"DevExpressXtraGridGridControl_FocusedViewtopic.htm\">GridControl.FocusedView<\/a> &#8211; returns the focused View;<\/li>\n<li><a href=\"DevExpressXtraGridGridControl_DefaultViewtopic.htm\">GridControl.DefaultView<\/a> &#8211; returns the currently maximized View;<\/li>\n<li>the <em>sender<\/em> parameter of View specific events;<\/li>\n<li><a href=\"DevExpressXtraGridViewsGridGridView_GetDetailViewtopic.htm\">GridView.GetDetailView<\/a> &#8211; returns a <a href=\"CustomDocument780.htm\">detail clone View<\/a> for a specific master row.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<\/blockquote>\n<p>\u8bd5\u6bd4\u8f83\uff1a<\/p>\n<pre class=\"lang:vbnet mark:20 decode:true \" title=\"GridView.RowCount \u4e0e GridView.DataRowCount \u533a\u522b\">Private Sub GridView1_MouseDown(sender As Object, e As MouseEventArgs) Handles GridView1.MouseDown\r\n        Dim view As GridView = TryCast(sender, GridView)\r\n        Dim hitInfo As GridHitInfo = view.CalcHitInfo(e.Location)\r\n        Select Case hitInfo.HitTest\r\n            Case GridHitTest.Column\r\n                SelectColumn(view, hitInfo)\r\n            Case Else                ' \r\n                view.OptionsSelection.MultiSelect = False\r\n                view.OptionsSelection.MultiSelectMode = GridMultiSelectMode.RowSelect\r\n        End Select\r\n End Sub\r\n\r\n Private Sub SelectColumn(ByRef View As GridView, ByRef hitinfo As GridHitInfo)\r\n        '\u5168\u9009\u5217(\u4e0d\u6392\u5217)\r\n        View.OptionsSelection.MultiSelect = True\r\n        View.OptionsSelection.MultiSelectMode = GridMultiSelectMode.CellSelect\r\n        View.OptionsCustomization.AllowSort = False\r\n        View.ClearSelection()\r\n\r\n        View.SelectCells(New GridCell(0, hitinfo.Column), New GridCell(View.DataRowCount - 1, hitinfo.Column))\r\n        View.OptionsCustomization.AllowSort = True\r\nEnd Sub<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>RowCount GridView.RowCount Property | WinForms Controls &hellip; <a href=\"http:\/\/www.ilezhi.cn\/?p=100231\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">GridView.RowCount \u4e0e GridView.DataRowCount \u7684\u533a\u522b<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[111,66,24,18,45,30,29],"class_list":["post-100231","post","type-post","status-publish","format-standard","hentry","category-program","tag-devexpress","tag-microsoft","tag-vb-net","tag-windows","tag-45","tag-30","tag-29"],"_links":{"self":[{"href":"http:\/\/www.ilezhi.cn\/index.php?rest_route=\/wp\/v2\/posts\/100231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.ilezhi.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ilezhi.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ilezhi.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ilezhi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=100231"}],"version-history":[{"count":0,"href":"http:\/\/www.ilezhi.cn\/index.php?rest_route=\/wp\/v2\/posts\/100231\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.ilezhi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=100231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ilezhi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=100231"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ilezhi.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=100231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}