Click here to Skip to main content
15,908,111 members
Home / Discussions / C#
   

C#

 
GeneralEject DVD-drive Pin
Stefan Troschuetz22-Feb-04 4:53
Stefan Troschuetz22-Feb-04 4:53 
GeneralRe: Eject DVD-drive Pin
Mazdak22-Feb-04 5:03
Mazdak22-Feb-04 5:03 
General[COM]DrCOM-Monitor Tool and more?[COM] Pin
kenokabe22-Feb-04 3:17
kenokabe22-Feb-04 3:17 
GeneralRe: [COM]DrCOM-Monitor Tool and more?[COM] Pin
Mazdak22-Feb-04 4:11
Mazdak22-Feb-04 4:11 
GeneralRe: [COM]DrCOM-Monitor Tool and more?[COM] Pin
kenokabe22-Feb-04 14:18
kenokabe22-Feb-04 14:18 
GeneralRe: [COM]DrCOM-Monitor Tool and more?[COM] Pin
Mazdak22-Feb-04 19:01
Mazdak22-Feb-04 19:01 
GeneralRe: [COM]DrCOM-Monitor Tool and more?[COM] Pin
kenokabe22-Feb-04 19:16
kenokabe22-Feb-04 19:16 
GeneralDataGrid, DataSet with DataTable and Sort Pin
gatemaster9922-Feb-04 1:40
gatemaster9922-Feb-04 1:40 
Hello!

I have a problem with the DataGrid Control in C#.

I've a form with some textboxes on it. In these textboxes you can search for Data.
If you enter something in a Textbox and press the Search-Button then I build a dynamic SQL-Statement like "Select * from Company where CompanyName like "%Test%"".
With this Select Statement I fill my Dataset.
If the DataSet returns 1 Row then the Row is Displayed in the Textboxes.
If more than 1 Row is found then I open a new form and pass him the DataSet build with the SQl-Statement.
In this new form (form2) I Bind the DataGrid to the Datatable and the Data is displayed well.
In form2 the user can select one DataRow and return to form1 where the selected row is displayed. Therefore form2 returns the index of the row in the Datatable in the Dataset.
Everything works fine until you use the sort possibility in the Datagrid.
After that the DataTable and the DataGrid are not longer synchronus.
I've searched the web and found something about the CurrencyManager and tried with it but without success.
The CurrencyManager.Position only shows the same position that is selected in the Datagrid not in the Position of the DataRow in the DataTable.

Here some of my code:

form1:

frmDisplaySearch frmDisplaySearch_ = new frmDisplaySearch(dsDB,DataTableName);
DialogResult dr_ = frmDisplaySearch_.ShowDialog();
if(dr_.Equals(DialogResult.OK))
{
Console.WriteLine("Ausgewählter Datensatz " + frmDisplaySearch_.SelectedRow);
NoRowSelected = frmDisplaySearch_.SelectedRow;
RowSelected = true;
}




from2:

public frmDisplaySearch(DataSet DataSetIn_,string DataTableNameIn_)
{
InitializeComponent();
DataTableName_ = DataTableNameIn_;
DataSetToDisplay_ = DataSetIn_;
grid.SetDataBinding(DataSetToDisplay_, DataTableName_);
cm_ = (CurrencyManager)this.BindingContext[DataSetToDisplay_,DataTableName_];
this.Text = DataTableName_;
this.grid.Size = new System.Drawing.Size(MaxGridWidth, MaxGridHeight);
AutoSizeCol();
}


private void btnOk_Click(object sender, System.EventArgs e)
{
Console.WriteLine("Ausgewählter Datensatz " + grid.CurrentCell.RowNumber);
Console.WriteLine("Ausgewählter Datensatz cm_" + cm_.Position);
SelectedRow = cm_.Position;
this.DialogResult = DialogResult.OK;
this.Close();
}

GeneralRe: DataGrid, DataSet with DataTable and Sort Pin
gatemaster9922-Feb-04 22:31
gatemaster9922-Feb-04 22:31 
GeneralRe: DataGrid, DataSet with DataTable and Sort Pin
Gigiwig23-Feb-04 11:56
Gigiwig23-Feb-04 11:56 
QuestionListViewItem.SubItems.BackColor ??? Pin
sps-itsec4622-Feb-04 0:54
sps-itsec4622-Feb-04 0:54 
AnswerRe: ListViewItem.SubItems.BackColor ??? Pin
ian mariano22-Feb-04 10:59
ian mariano22-Feb-04 10:59 
GeneralWeb request coding problem Pin
Niels Penneman22-Feb-04 0:14
Niels Penneman22-Feb-04 0:14 
Generalgetting common directory Pin
Rob Tomson21-Feb-04 23:56
Rob Tomson21-Feb-04 23:56 
GeneralGetting a unique system identifier Pin
mablebee21-Feb-04 22:18
mablebee21-Feb-04 22:18 
GeneralRe: Getting a unique system identifier Pin
Mazdak22-Feb-04 4:05
Mazdak22-Feb-04 4:05 
GeneralSelect Random Pin
Anonymous21-Feb-04 20:06
Anonymous21-Feb-04 20:06 
GeneralRe: Select Random Pin
Mazdak21-Feb-04 20:15
Mazdak21-Feb-04 20:15 
GeneralRe: Select Random Pin
Anonymous22-Feb-04 19:09
Anonymous22-Feb-04 19:09 
GeneralRe: Select Random Pin
turbochimp25-Feb-04 11:31
turbochimp25-Feb-04 11:31 
GeneralCustom Control Problem Pin
Guinness4Strength21-Feb-04 19:59
Guinness4Strength21-Feb-04 19:59 
GeneralRe: Custom Control Problem Pin
Dan_P21-Feb-04 22:02
Dan_P21-Feb-04 22:02 
GeneralRe: Custom Control Problem Pin
Guinness4Strength22-Feb-04 5:21
Guinness4Strength22-Feb-04 5:21 
GeneralSetting visibility of parent form from child. Pin
POnfri21-Feb-04 12:58
POnfri21-Feb-04 12:58 
GeneralRe: Setting visibility of parent form from child. Pin
POnfri21-Feb-04 15:09
POnfri21-Feb-04 15:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.