// Set the data source xdgField.DataSource = MyDataSource; // Select the first record if (xdgField.Records.Count>0) { DataRecord firstRecord = (DataRecord)xdgField.Records[0]; firstRecord.IsSelected = true; xdgField.ActiveRecord = firstRecord; }
firstRecord = xdgField.RecordManager.Sorted[0]; firstRecord = (DataRecord)xdgField.ViewableRecords[0];
public Window1()
{
InitializeComponent(); this.xamDataGrid1.InitializeRecord += new EventHandler<Infragistics.Windows.DataPresenter..Events.InitializeRecordEventArgs>(xamDataGrid1_InitializeRecord);
InitializeComponent();
this.xamDataGrid1.InitializeRecord += new EventHandler<Infragistics.Windows.DataPresenter..Events.InitializeRecordEventArgs>(xamDataGrid1_InitializeRecord);
}
void xamDataGrid1_InitializeRecord(object sender, Infragistics.Windows.DataPresenter.Events.InitializeRecordEventArgs e)
// Check member variable to see if we have selected the first record yet.
if (this._firstRecordSelected == false) { e.Record.IsSelected = true; this._firstRecordSelected = true; }
if (this._firstRecordSelected == false)
e.Record.IsSelected = true; this._firstRecordSelected = true;
e.Record.IsSelected = true;
this._firstRecordSelected = true;
"jsjslim" wrote in message news:23254@forums.infragistics.com...Hi, I'm currently having problems trying to select the first record in the grid and set it as the active record. Please help. // Set the data source xdgField.DataSource = MyDataSource; // Select the first record if (xdgField.Records.Count>0) { DataRecord firstRecord = (DataRecord)xdgField.Records[0]; firstRecord.IsSelected = true; xdgField.ActiveRecord = firstRecord; } As shown in the code, the first time this is executed, the records count is always 0. I've tried other things such as setting the DataSource to null before setting it to the new datasource (and even to set the same datasource twice), but the count is still 0 on its first run. Please help. Thanks! [edit] I've also tried other methods: firstRecord = xdgField.RecordManager.Sorted[0]; firstRecord = (DataRecord)xdgField.ViewableRecords[0]; but none of them work because the first time they're called, the records count = 0 http://forums.infragistics.com/forums/p/5099/23254.aspx#23254