TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
micnie_2020
NA
137
0
After SortMode Automatic, my function doesn't work
Nov 3 2011 10:05 PM
Hi All,
I trying to sort the datagrid grid column, after sorting i want it to trigger the function hide the row which the column data row equal to "-". Unfortunately. It's
NOT
working. But i put breakpoint. It's actually trigger the fuction & visble=false as well. Look Funny, it's doesn't hide my "-" row.
Please Advise.
Here is my code 2 method i used, both failed:
Method I
Datagrid Column
-----------------
this.dgvtbcRevByYearTotalRc.DataPropertyName = "value_total_rc";
this.dgvtbcRevByYearTotalRc.HeaderText = "Total...";
this.dgvtbcRevByYearTotalRc.Name = "dgvtbcRevsByYearTotalRc";
this.dgvtbcRevByYearTotalRc.ReadOnly = true;
this.dgvtbcRevByYearTotalRc.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
this.dgvtbcRevByYearTotalRc.Width = 60;
this.dgvtbcRevByYearTotalRc.DataGridView.Click += new System.EventHandler(this.lblTotalYTDDrillDownCaption_Click);
private void lblTotalYTDDrillDownCaption_Click(object sender, EventArgs e)
{
this.dgvtbcRevByYearTotalRc.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
///Added by micheale to hide "-" row
foreach (DataGridViewRow item in dgvRevByYear.Rows)
{
dgvRevByYear.CurrentCell = null; // To avoid Row associated with the currency manager's position cannot be made invisible
if (item.Cells["dgvtbcRevenuesByYearTotalRc"].FormattedValue.ToString() == "-")
{
item.Visible = false;
}
}
}
Method II
Datagrid Column
-----------------
this.dgvtbcRevByYearTotalRc.DataPropertyName = "value_total_rc";
this.dgvtbcRevByYearTotalRc.HeaderText = "Total...";
this.dgvtbcRevByYearTotalRc.Name = "dgvtbcRevsByYearTotalRc";
this.dgvtbcRevByYearTotalRc.ReadOnly = true;
this.dgvtbcRevByYearTotalRc.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
this.dgvtbcRevByYearTotalRc.Width = 60;
this.dgvtbcRevByYearTotalRc.DataGridView.Click += new System.EventHandler(this.lblTotalYTDDrillDownCaption_Click);
private void lblTotalYTDDrillDownCaption_Click(object sender, EventArgs e)
{
///Added by micheale to hide "-" row
foreach (DataGridViewRow item in dgvRevByYear.Rows)
{
dgvRevByYear.CurrentCell = null; // To avoid Row associated with the currency manager's position cannot be made invisible
if (item.Cells["dgvtbcRevenuesByYearTotalRc"].FormattedValue.ToString() == "-")
{
item.Visible = false;
}
}
}
Thank you.
Regards,
Micheale
Reply
Answers (
4
)
foreach passes object by value?
Change Web config Values using C#.net tool