//I hope this is the info your looking for
//The NumberTB property VS window under Data->DataBinding->Text says
configMgmtLogDS - StevesConfigMgmtLog.DocumentNumber
//and nothing else (Tag, etc)
//The InitializeComponent() says
this.dGrid.DataSource = this.configMgmtLogDS.StevesConfigMgmtLog;
this.numberTB.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.configMgmtLogDS, "StevesConfigMgmtLog.DocumentNumber"));
ConfigMgmtLog_Load() //ConfigMgmtLog is Access dB
{
//opens the database and fills the DS
LoadDataFromDataBase();
//load the DataTable for the dbaseTableName, 1 per class
LoadDataTable();
//sets the sort and binds the DataView to the DataGrid
setGridSort(configMgmtLogDS, dGrid, gridSortedByColumn, numberZero);
setGridTableStyle(dGrid, configMgmtLogDS);
//change column names and width
setGridNamesAndWidth(dGrid);
bindDataBase_To_DataGrid(); //binding at startup (no event)
OrganizeDataGridColums(dGrid); //
}
bindDataBase_To_DataGrid()
{
int idColumnNo = getDataSetColumnNumber(configMgmtLogDS, dbaseTableName,
"ID");
if (dGrid.CurrentRowIndex >= 0)
{
int contentsDataGridID = (int) (dGrid[dGrid.CurrentRowIndex, idColumnNo]);
int matchingDataSetRowNumber =
findMatchingDataGridDataSetRowNumber(contentsDataG ridID);
if (matchingDataSetRowNumber >= 0)
this.BindingContext[configMgmtLogDS, dbaseTableName].Position =
matchingDataSetRowNumber;
}
}
"Nicholas Paldino [.NET/C# MVP]" wrote:
Steve,
Are you setting up the data binding correctly? Is the data source that
you are connecting the grid to the same as the data source that you are
binding the textboxes to?
Can you show a piece of code that shows the issue?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Steve B." <St****@discussions.microsoft.com> wrote in message
news:52**********************************@microsof t.com...I have a DataGrid on the left and TextBoxes (TB) on the right. The TB's
reflect the contents of the grid cells.
Sorting of columns (both thru VS and programmatically) work fine except,
when the form/grid first opens up and the grid is immediately sorted the
TB
don't reflect the sorted data of the First row of the grid.
Note: Initially the black grid indicator arrow points to the first row. If
the user choses another row and then sorts the TB's reflect proper data.
//setGridSort(DataSet dataSet, DataGrid dataGrid, string
sortTableColumnName, int tableNo)
DataView dataView = createNewDataView();
dataView = dataSet.Tables[tableNo].DefaultView;
dataView.Sort = sortTableColumnName;
dataGrid.DataSource = dataView;
//incorrect - not the correct cell value of the grid for the TB
numberTB.Text = (string) (dataGrid[dataGrid.CurrentRowIndex, columnNo]);
Steve