B
BBFrost
Win2000
..Net 1.1 SP1
c# using Visual Studio
Ok, I'm currently in a "knock down - drag out" tussle with the .Net 1.1
datagrid.
I've come to realize that a 'block' of rows highlighted within a datagrid doone row may be 'selected' in a datagrid. By selected row I mean the row
pointer within the datagrid datasource.
I was trying to set up a process that would allow the user to select a set
of rows in DataGrid #1 and then mash a button that would transfer those rows
to DataGrid #2. The rows would then be removed from DataGrid #1.
I've tried a couple iterations of the following code.
1st try ... this code simply moved the record at the datagrid record pointer
and ignored the other highlighted records. Apparently the dv.Delete( );
statement somehow unhighlights the rest of the datagrid records.
//' DERIVE the source table for the Search Results Grid.
CurrencyManager cm = (CurrencyManager)this.BindingContext
[this.dgSearchResults.DataSource,this.dgSearchResults.DataMember];
DataView dv = (DataView)cm.List;
for(int i=0; i < dv.Count; ++i)
{
if(this.dgSearchResults.IsSelected(i))
{
mDs.Tables[this.mSelectedDirectoryIDsTableName].Rows.Add
(new Object[] {
dv["directory_id"],
dv["display_name"],
dv["street1"],
dv["city"],
dv["last_updt_date"]
});
dv.Delete( );
}
}
2nd try ...
This example moves all of the selected datagrid #1 records to datagrid #2,
deletes the datagrid #1 record designated by the datagrid #1 record pointer
and leaves the other 'formerly highlighted' records in datagrid #1 and
unhighlighted. This is stronger proof that dv.Delete( ); causes the
records in datagrid #1 to be unselected.
//' DERIVE the source table for the Search Results Grid.
CurrencyManager cm = (CurrencyManager)this.BindingContext
[this.dgSearchResults.DataSource,this.dgSearchResults.DataMember];
DataView dv = (DataView)cm.List;
for(int i=0; i < dv.Count; ++i)
{
if(this.dgSearchResults.IsSelected(i))
{
mDs.Tables[this.mSelectedDirectoryIDsTableName].Rows.Add
(new Object[] {
dv["directory_id"],
dv["display_name"],
dv["street1"],
dv["city"],
dv["last_updt_date"]
});
}
}
for(int i=0; i < dv.Count; ++i)
{
if(this.dgSearchResults.IsSelected(i))
{
dv.Delete( );
}
}
The only solution I can see here is to pass all the highlighted datagrid #1
records and 'tag' them in some way; then write a method to hunt the tagged
records down, move them to datagrid #2 and then delete them from datagrid
#1.
After working with c# for more than 2 years I still find myself stunned at
how much of a PIA seemingly simple processes like this can be. I'm REALLY
hoping some of you wizards out there have a better / more elegant solution
than this. I've got to admit that even after all this time the Currency
Manager mechanism is still a mystery to me ... if it wasn't for help from
this group I'd have been sunk long ago.
Thanks in advance.
Barry
in Oregon
(e-mail address removed)
..Net 1.1 SP1
c# using Visual Studio
Ok, I'm currently in a "knock down - drag out" tussle with the .Net 1.1
datagrid.
I've come to realize that a 'block' of rows highlighted within a datagrid doone row may be 'selected' in a datagrid. By selected row I mean the row
pointer within the datagrid datasource.
I was trying to set up a process that would allow the user to select a set
of rows in DataGrid #1 and then mash a button that would transfer those rows
to DataGrid #2. The rows would then be removed from DataGrid #1.
I've tried a couple iterations of the following code.
1st try ... this code simply moved the record at the datagrid record pointer
and ignored the other highlighted records. Apparently the dv.Delete( );
statement somehow unhighlights the rest of the datagrid records.
//' DERIVE the source table for the Search Results Grid.
CurrencyManager cm = (CurrencyManager)this.BindingContext
[this.dgSearchResults.DataSource,this.dgSearchResults.DataMember];
DataView dv = (DataView)cm.List;
for(int i=0; i < dv.Count; ++i)
{
if(this.dgSearchResults.IsSelected(i))
{
mDs.Tables[this.mSelectedDirectoryIDsTableName].Rows.Add
(new Object[] {
dv["directory_id"],
dv["display_name"],
dv["street1"],
dv["city"],
dv["last_updt_date"]
});
dv.Delete( );
}
}
2nd try ...
This example moves all of the selected datagrid #1 records to datagrid #2,
deletes the datagrid #1 record designated by the datagrid #1 record pointer
and leaves the other 'formerly highlighted' records in datagrid #1 and
unhighlighted. This is stronger proof that dv.Delete( ); causes the
records in datagrid #1 to be unselected.
//' DERIVE the source table for the Search Results Grid.
CurrencyManager cm = (CurrencyManager)this.BindingContext
[this.dgSearchResults.DataSource,this.dgSearchResults.DataMember];
DataView dv = (DataView)cm.List;
for(int i=0; i < dv.Count; ++i)
{
if(this.dgSearchResults.IsSelected(i))
{
mDs.Tables[this.mSelectedDirectoryIDsTableName].Rows.Add
(new Object[] {
dv["directory_id"],
dv["display_name"],
dv["street1"],
dv["city"],
dv["last_updt_date"]
});
}
}
for(int i=0; i < dv.Count; ++i)
{
if(this.dgSearchResults.IsSelected(i))
{
dv.Delete( );
}
}
The only solution I can see here is to pass all the highlighted datagrid #1
records and 'tag' them in some way; then write a method to hunt the tagged
records down, move them to datagrid #2 and then delete them from datagrid
#1.
After working with c# for more than 2 years I still find myself stunned at
how much of a PIA seemingly simple processes like this can be. I'm REALLY
hoping some of you wizards out there have a better / more elegant solution
than this. I've got to admit that even after all this time the Currency
Manager mechanism is still a mystery to me ... if it wasn't for help from
this group I'd have been sunk long ago.
Thanks in advance.
Barry
in Oregon
(e-mail address removed)