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.

Make the Grid inactive except the current row.

Thread ID:

Created:

Updated:

Platform:

Replies:

65519 Jul 26,2007 10:18 AM Jul 26,2007 08:34 PM Windows Forms 3
loading
Tags: GridControl
ngp
Asked On July 26, 2007 10:18 AM

Haneef,

I have a grid where I can add a new row on a button click.

1. I need to set the new row added as the Active/Current/Selected/pointed Row
2. I need the rest of the rows to be disabled. and the textcolor = SystemColors.InactiveCaptionText

It would be great if you could provide a small code snippet to do the same.

Thanks a lot.
Grace

Rajagopal [Syncfusion]
Replied On July 26, 2007 11:30 AM

Hi Grace,

Thanks for your interest in Syncfusion Products.

1. To set the new row added as the active current row, try the code below in your button click handler.

int lastAddedRecord = this.gridGroupingControl1.Table.Records.Count-1;
this.gridGroupingControl1.Table.Records[lastAddedRecord].SetCurrent();

2. To disable all the rows except the current row, please try the code below in the QueryCellStyleInfo event of the GridGroupingControl.

void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
Element el = e.TableCellIdentity.DisplayElement;
if (el.Kind == DisplayElementKind.Record)
{
Record rec = el.GetRecord();
if (e.TableCellIdentity.ColIndex > 0 && e.TableCellIdentity.Table.CurrentRecord != rec)
{
e.Style.TextColor = SystemColors.InactiveCaptionText;
e.Style.CellType = "Static";
}
}
}

Please try the above code and let me know if this helps.

Have a nice time.
Regards,
Rajagopal

ngp
Replied On July 26, 2007 01:07 PM

Hi Rajagopal,

My underlying datasource is ArrayList and Not Datatable

What woudl be the change?

Thanks
Grace



>Hi Grace,

Thanks for your interest in Syncfusion Products.

1. To set the new row added as the active current row, try the code below in your button click handler.

int lastAddedRecord = this.gridGroupingControl1.Table.Records.Count-1;
this.gridGroupingControl1.Table.Records[lastAddedRecord].SetCurrent();

2. To disable all the rows except the current row, please try the code below in the QueryCellStyleInfo event of the GridGroupingControl.

void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
Element el = e.TableCellIdentity.DisplayElement;
if (el.Kind == DisplayElementKind.Record)
{
Record rec = el.GetRecord();
if (e.TableCellIdentity.ColIndex > 0 && e.TableCellIdentity.Table.CurrentRecord != rec)
{
e.Style.TextColor = SystemColors.InactiveCaptionText;
e.Style.CellType = "Static";
}
}
}

Please try the above code and let me know if this helps.

Have a nice time.
Regards,
Rajagopal

Rajagopal [Syncfusion]
Replied On July 26, 2007 08:34 PM

Hi Grace,

If you are using Arraylist as the datasource for the grid, then grid does not respond to changes in the data source, the data source has to implement the IBindingList interface. DataTable does this, but ArrayList does not. But you can derive an ArrayList so it does implement IBindingList. If you do this, then the grid should display the changes as they are made to the arraylist.

Please refer the sample below that meets your requirements
http://websamples.syncfusion.com/samples/Grid.Windows/F65519/main.htm

Let me know if you have any other questions.
Regards,
Rajagopal

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.

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.

;