-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: LovedJohnySmith
Message 2 in Discussion
Hey Dude: You can achive this task using HitTest Property. it
will give you the current hit area. from that, you can highlight the color.
When you click on a cell and the whole cell gets highlighted. so please use the
following function to get that behavior: protected override void
OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
DataGrid.HitTestInfo hitTestInfo = this.HitTest(e.X, e.Y);
if (hitTestInfo.Type == HitTestType.ColumnResize
|| hitTestInfo.Type == HitTestType.RowResize) {
return;
} base.OnMouseDown(e);
if ( hitTestInfo.Type == HitTestType.Cell) {
SelectRow(hitTestInfo.Row);
}
return;
} That function reacts to the mouse click and calls my other function,
SelectRow, which in turn calls HighlightRow... public void SelectRow(int
index)
{
HighlightRow(index);
this.CurrentRowIndex = index;
return;
} int highlightedRow = -1; // we use -1 to mean no selection
private void HighlightRow(int index)
{
CurrencyManager currencyManager;
currencyManager = (CurrencyManager) this.BindingContext[this.DataSource];
int rowCount = currencyManager.Count;
if (index < 0 || index > rowCount - 1)
return;
if (highlightedRow > -1 && highlightedRow < rowCount)
this.UnSelect(highlightedRow);
this.Select(index);
highlightedRow = index;
return;
}
Finally, one more function: protected override void
OnCurrentCellChanged(System.EventArgs e)
{
HighlightRow(this.CurrentCell.RowNumber);
base.OnCurrentCellChanged(e);
return; }
and have a look at the following URL for excellent example.
http://www.codeproject.com/csharp/custom_datagridcolumnstyl.asp Thanx, smith
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you
received this message by mistake, please click the "Remove" link below. On the
pre-addressed e-mail message that opens, simply click "Send". Your e-mail
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]