Click here to Skip to main content
15,918,742 members
Home / Discussions / C#
   

C#

 
GeneralRe: to increse size of a panel, its override another controls Pin
myms.net2-Apr-09 1:38
myms.net2-Apr-09 1:38 
GeneralRe: to increse size of a panel, its override another controls Pin
Henry Minute2-Apr-09 1:42
Henry Minute2-Apr-09 1:42 
QuestionHow to split & merge mpeg video files Pin
pravat_SABAT2-Apr-09 0:37
pravat_SABAT2-Apr-09 0:37 
QuestionRe: How to split & merge mpeg video files Pin
King Julien2-Apr-09 1:20
King Julien2-Apr-09 1:20 
QuestionLoading data from selected row in datagridview into dialog box Pin
Martin310882-Apr-09 0:25
Martin310882-Apr-09 0:25 
AnswerRe: Loading data from selected row in datagridview into dialog box Pin
Henry Minute2-Apr-09 1:15
Henry Minute2-Apr-09 1:15 
GeneralRe: Loading data from selected row in datagridview into dialog box Pin
Martin310882-Apr-09 2:07
Martin310882-Apr-09 2:07 
GeneralRe: Loading data from selected row in datagridview into dialog box Pin
Henry Minute2-Apr-09 2:37
Henry Minute2-Apr-09 2:37 
Hi Martin,

The DataGridView has a property called SelectedRows, which is a collection of the rows currently selected. There is also an event called OnRowEnter. Both of these give you access to the DataGridViewRow selected by your user. What is needed is a way to track that row and make it available to your calling form when the dialog closes. So:

1. add a private field to your dialog.
private  DataGridViewRow selectedRow;

2. add a public property so that it can be accessed from outside the dialog
public DataGridViewRow SelectedRow
{
    get
    {
        return this.selectedRow;
    }
}


3. If you elect to use OnRowEnter, for example, you can store the row in the private field. In the event handler:
this.selectedRow = this.dataGridView1.Rows[e.rowIndex];


then every time a new row is entered that row is stored in your field.

4. In your calling form:
if (datagridDialog.ShowDialog() == DialogResult.OK)
{
    this.FillData(datagridDialog.SelectedRow);
}

private void FillData(DataGridViewRow loadedRow)
{
    this.usernameTextBox.Text = loadedRow.Cells["UserName"].Value.ToString();
    etc.
}


Hope this gives you some idea.

It has just occurred to me that your calling forms controls might be databound, if so this won't work, please let me know.

Henry Minute

Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”

GeneralRe: Loading data from selected row in datagridview into dialog box Pin
Martin310882-Apr-09 23:15
Martin310882-Apr-09 23:15 
GeneralRe: Loading data from selected row in datagridview into dialog box Pin
Henry Minute3-Apr-09 2:55
Henry Minute3-Apr-09 2:55 
GeneralRe: Loading data from selected row in datagridview into dialog box Pin
Martin310883-Apr-09 3:44
Martin310883-Apr-09 3:44 
QuestionMessageBox is displayed twice.... Help! Pin
Rajdeep.NET is BACK2-Apr-09 0:05
Rajdeep.NET is BACK2-Apr-09 0:05 
AnswerRe: MessageBox is displayed twice.... Help! Pin
J4amieC2-Apr-09 0:09
J4amieC2-Apr-09 0:09 
GeneralRe: MessageBox is displayed twice.... Help! Pin
MumbleB2-Apr-09 0:12
MumbleB2-Apr-09 0:12 
GeneralRe: MessageBox is displayed twice.... Help! Pin
Spunky Coder2-Apr-09 2:02
Spunky Coder2-Apr-09 2:02 
GeneralRe: MessageBox is displayed twice.... Help! Pin
Rajdeep.NET is BACK2-Apr-09 0:15
Rajdeep.NET is BACK2-Apr-09 0:15 
GeneralRe: MessageBox is displayed twice.... Help! Pin
J4amieC2-Apr-09 0:19
J4amieC2-Apr-09 0:19 
GeneralRe: MessageBox is displayed twice.... Help! Pin
Dan Neely2-Apr-09 3:20
Dan Neely2-Apr-09 3:20 
RantRe: MessageBox is displayed twice.... Help! Pin
Vikram A Punathambekar2-Apr-09 0:23
Vikram A Punathambekar2-Apr-09 0:23 
GeneralRe: MessageBox is displayed twice.... Help! Pin
Colin Angus Mackay2-Apr-09 0:36
Colin Angus Mackay2-Apr-09 0:36 
GeneralRe: MessageBox is displayed twice.... Help! Pin
akyriako782-Apr-09 2:06
akyriako782-Apr-09 2:06 
GeneralRe: MessageBox is displayed twice.... Help! Pin
HuntingWabbits2-Apr-09 2:51
HuntingWabbits2-Apr-09 2:51 
GeneralRe: MessageBox is displayed twice.... Help! Pin
akyriako782-Apr-09 2:07
akyriako782-Apr-09 2:07 
JokeRe: MessageBox is displayed twice.... Help! Pin
Vikram A Punathambekar2-Apr-09 0:21
Vikram A Punathambekar2-Apr-09 0:21 
GeneralRe: MessageBox is displayed twice.... Help! Pin
J4amieC2-Apr-09 0:24
J4amieC2-Apr-09 0:24 

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.