Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to retrieve multiple values from mutilple row selected datagrid

Status
Not open for further replies.

jl3574

Programmer
Jun 5, 2003
76
CA
Hello,
I have a Datagrid when double click retrieves the column i want in the row where i click.

private void DataGrid_Click(object sender,System.EventArgs e)
{
BindingManagerBase bm = this.WorkBoardMain.BindingContext[this.WorkBoardMain.DataSource, this.WorkBoardMain.DataMember];
DataRow dr = ((DataRowView)bm.Current).Row;
int ColumnID = (int)dr["ColumnID"];
}

// this works fine as it retrieves value from ColumnID from one row selected however i want to highlight multiple rows in the datagrid and some how able to receive all the value that has the row highlighted.

//please help thanx
//
 
Are you saying that you would want the user (you in this case) to be able to select multiple rows at a time and you want to recieve the ids from the selected rows?
 
Yes i want the user to hold ctrl and click and highlight mutilple rows
then some function like an onclick on a button which will receive the ids from all the selected (Highlighted ) rows
 
Select the rows you want via the ctrl key, then activate the process via a button click.

At that point, get all selected rows from the grid and loop through each of them individually, performing whatever work you want to do on each.
 
I think it would be easier to add a checkbox to each row then run through and retrieve the ID of each row that is checked. You could also name the checkbox with the databound item's primary key to make it easier.
 
but, if i select rows with ctrl key then activate the button click the only function i know with the Datagrid is CurrentRowSelect (or close to that) but that only give me the last row highlighted and not all the highlighted row..

and to Bradw96511 i could use a checkbox column but in my datagrid i really don't have enough room to do so and i realy want to extract it from current highlighted row.

i can't seem to find a proper function to do that and to remind you that i am running a windows application project using VS.net c#
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top