We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Need Help in applying color to selected row in a DBG

Thread ID:

Created:

Updated:

Platform:

Replies:

74436 Jun 13,2008 03:28 AM UTC Jun 16,2008 06:40 AM UTC Windows Forms 3
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On June 13, 2008 03:28 AM UTC

i am displaying rows into a DBG.and i placed a context menu strip control on it.
after displaying rows in a grid i am selecting a row and applying a color to that row by clicking on contextmenu strip button
but it is not applying that color

my code is
private void Form1_Load(object sender, EventArgs e)
{

string con = "data source=SERVER;uid=sa;pwd=safertek;database=master";
string cmd = " select * from emp";
SqlDataAdapter da = new SqlDataAdapter(cmd, con);
DataSet ds = new DataSet();
da.Fill(ds, "emp");
gridDataBoundGrid1.DataSource = ds.Tables[0];

this.gridDataBoundGrid1[1, 1].BackColor = Color.GreenYellow;
this.gridDataBoundGrid1[1, 1].TextColor = Color.RoyalBlue;
this.gridDataBoundGrid1[1, 1].CellType = "TextBox";

}

private void buttonAdv1_Click(object sender, EventArgs e)
{
Application.Exit();
}

private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
int i = gridDataBoundGrid1.CurrentCell.RowIndex;
int c = gridDataBoundGrid1.CurrentCell.ColIndex;
this.gridDataBoundGrid1[i, c].BackColor = Color.GreenYellow;
}



Sri Rajan [Syncfusion]
Replied On June 13, 2008 09:43 AM UTC

Hi Hari,

Thank you for your interest in Syncfusion products.

You need to handle QueryCellInfo event to change the back color of the selected cell. Here is the code.

//To Change the backcolor of selected cell.
void Model_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
{
if ((e.RowIndex == i && i!=-1)&& (e.ColIndex == c && c!=-1))
{
e.Style.BackColor = Color.Red;
i = -1;
c = -1;
}
else
{
if(e.RowIndex>0 && e.ColIndex>0)
e.Style.BackColor = Color.White;
}
}

int i = -1, c = -1;
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
i = this.gridDataBoundGrid1.CurrentCell.RowIndex;
c = this.gridDataBoundGrid1.CurrentCell.ColIndex;
this.gridDataBoundGrid1.Focus();
}


Please let me know if this helps.

Best Regards,
Srirajan


Administrator [Syncfusion]
Replied On June 14, 2008 06:31 AM UTC

ThankYou Srirajan

Can you plz provide any documentation regarding GridBoundDataGrid events like Model_QueryCellInfo,
PrepareViewStyleInfo,
CurrentCellAcceptedChanges..
thanks in advance



Sri Rajan [Syncfusion]
Replied On June 16, 2008 06:40 AM UTC

Hi Hari,

Thank you for your continued interest in Syncfusion products.

Here is the documentation for the events of GridDataBoundGrid control.
http://www2.syncfusion.com/cref_63/cref_files/grid_win/html/5293b51c-7841-41b3-cffa-5b1322dda62a.htm#eventTableToggle

Please let me know if this helps.

Best Regards,
Srirajan.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;