c# - Setting last row as Frozen in DataGridView -
my grid has 40 rows. 20 rows can displayed @ time, grid has scrollbar.
i want freeze lastly row of datagridview, scrollbar disappears. how solve this?
you using datagridviewrow.frozen
property: see documentation here.
this property lets maintain 1 or several rows of of import info in place when user scrolls through datagridview. all rows above frozen row frozen.
which means, if "freeze" lastly row, rows above frozen row frozen too; meaning scrollbar gets, because freeze lastly row, removed.
to reply question; can not individually "freeze" only lastly row, not in nature of frozen
property.
there workaround documented in this document. however, in vb, have translate c# yourself.
actually looking farther found this document, has little illustration in c#. appears have bugs might going towards goal.
public partial class mydatagridview : datagridview { public statusstrip footer { { homecoming (statusstrip)this.controls["footer"]; } } private bool _footervisible; [browsable(false)] /// /// sets or gets value specifying if footer bar shown or not /// public bool footervisible { { homecoming _footervisible; } set { _footervisible = value; this.controls["footer"].visible = _footervisible; } } public mydatagridview() { initializecomponent(); statusstrip footer = new statusstrip(); footer.name = "footer"; footer.forecolor = color.black; this.controls.add(footer); ((statusstrip)this.controls["footer"]).visible = _footervisible; ((statusstrip)this.controls["footer"]).visiblechanged += new eventhandler(rdatagridview_visiblechanged); this.scroll += new scrolleventhandler(rdatagridview_scroll); _footeritems = ((statusstrip)this.controls["footer"]).items; } }
the above stated code can used usercontrol , inherits datagridview
. adds footer can fill lastly row of choice. scrollbar still visible if set frozen
property of rows false.
c# winforms datagridview
No comments:
Post a Comment