Click here to Skip to main content
16,005,038 members
Home / Discussions / C#
   

C#

 
AnswerRe: bool delegate Pin
Christian Graus20-Aug-09 0:05
protectorChristian Graus20-Aug-09 0:05 
AnswerRe: bool delegate Pin
N a v a n e e t h20-Aug-09 0:11
N a v a n e e t h20-Aug-09 0:11 
AnswerRe: bool delegate Pin
DaveyM6920-Aug-09 0:11
professionalDaveyM6920-Aug-09 0:11 
GeneralRe: bool delegate Pin
bonzaiholding20-Aug-09 0:36
bonzaiholding20-Aug-09 0:36 
GeneralRe: bool delegate Pin
DaveyM6920-Aug-09 1:38
professionalDaveyM6920-Aug-09 1:38 
GeneralRe: bool delegate Pin
DaveyM6920-Aug-09 1:52
professionalDaveyM6920-Aug-09 1:52 
GeneralRe: bool delegate Pin
bonzaiholding20-Aug-09 2:40
bonzaiholding20-Aug-09 2:40 
Generalstore datagridview items under a button [modified] Need help! Pin
Member 474292219-Aug-09 23:43
Member 474292219-Aug-09 23:43 
Hello everyone,

i'm trying to store the rows from a datagridview under the name property of a button.
there for i use the following code:

private void button1_Click(object sender, EventArgs e)
{
    Button wacht = new Button();

    foreach (DataGridViewRow row in dataGridView1.Rows)
    {
        wacht.Name += row.ToString() + System.Convert.ToChar(127);
    }

    wacht.Text = flowLayoutPanel1.Controls.Count.ToString();
    wacht.Width = 75;
    wacht.Height = 63;
    wacht.Click += new EventHandler(wacht_Click);
    flowLayoutPanel2.Controls.Add(wacht);
    dataGridView1.Rows.Clear();

}

void wacht_Click(object sender, EventArgs e)
{
    Button currentButton = sender as Button;
    string[] lists = currentButton.Name.Split(System.Convert.ToChar(127));

    foreach (string s1 in lists)
    {
        if (s1.Trim().Length > 0)
        {
            dataGridView1.Rows.Add(s1);
        }
    }
    flowLayoutPanel2.Controls.Remove(currentButton);
}

but the code above doesn't work because there are no value's in the row cells.

first i wanted to use the listbox control to do this:

private void button3_Click(object sender, EventArgs e)

        {// flowLayoutPanel1 is a panel control

            Button wacht = new Button();

            wacht.Text = flowLayoutPanel1.Controls.Count.ToString();

            foreach (object o1 in listBox1.Items)

                wacht.Name += o1.ToString() + System.Convert.ToChar(127);

 

            wacht.Width = 68;

            wacht.Height = 54;

            wacht.BackColor = System.Drawing.Color.LightYellow;

            wacht.Click += new EventHandler(wacht_Click);

            flowLayoutPanel1.Controls.Add(wacht);

            listBox1.Items.Clear();  

        }

 

        private void wacht_Click(object sender, EventArgs e)

        {

            Button currentButton = (Button)sender;

            string[] lists = currentButton.Name.Split(System.Convert.ToChar(127));

            foreach (string s1 in lists)                

           if (s1.Trim().Length > 0)

                   listBox1.Items.Add(s1);

            flowLayoutPanel1.Controls.Remove(currentButton);  

        }

}

the code above works for the listbox but how to convert it so it is useable for the datagridview control?

maybe its a bit confusing but i hope someone could help me out!

modified on Thursday, August 20, 2009 6:24 AM

GeneralRe: store datagridview items under a button [modified] Need help! Pin
OriginalGriff20-Aug-09 1:40
mveOriginalGriff20-Aug-09 1:40 
GeneralRe: store datagridview items under a button [modified] Need help! Pin
Member 474292220-Aug-09 2:08
Member 474292220-Aug-09 2:08 
GeneralRe: store datagridview items under a button [modified] Need help! Pin
OriginalGriff20-Aug-09 9:16
mveOriginalGriff20-Aug-09 9:16 
GeneralRe: store datagridview items under a button [modified] Need help! Pin
Member 474292220-Aug-09 21:38
Member 474292220-Aug-09 21:38 
GeneralRe: store datagridview items under a button [modified] Need help! Pin
OriginalGriff20-Aug-09 21:52
mveOriginalGriff20-Aug-09 21:52 
GeneralRe: store datagridview items under a button [modified] Need help! Pin
Member 474292222-Aug-09 2:08
Member 474292222-Aug-09 2:08 
QuestionGeneric Question - Implementing IEnumerable Pin
Programm3r19-Aug-09 23:37
Programm3r19-Aug-09 23:37 
AnswerRe: Generic Question - Implementing IEnumerable Pin
N a v a n e e t h20-Aug-09 0:08
N a v a n e e t h20-Aug-09 0:08 
GeneralRe: Generic Question - Implementing IEnumerable Pin
Programm3r20-Aug-09 1:40
Programm3r20-Aug-09 1:40 
AnswerRe: Generic Question - Implementing IEnumerable Pin
Nicholas Butler20-Aug-09 0:10
sitebuilderNicholas Butler20-Aug-09 0:10 
GeneralRe: Generic Question - Implementing IEnumerable Pin
Programm3r20-Aug-09 2:06
Programm3r20-Aug-09 2:06 
QuestionWhy doesn´t work the Code? Pin
nhqlbaislwfiikqraqnm19-Aug-09 22:48
nhqlbaislwfiikqraqnm19-Aug-09 22:48 
AnswerRe: Why doesn´t work the Code? Pin
padmanabhan N19-Aug-09 22:59
padmanabhan N19-Aug-09 22:59 
GeneralRe: Why doesn´t work the Code? Pin
nhqlbaislwfiikqraqnm19-Aug-09 23:05
nhqlbaislwfiikqraqnm19-Aug-09 23:05 
GeneralRe: Why doesn´t work the Code? Pin
padmanabhan N19-Aug-09 23:15
padmanabhan N19-Aug-09 23:15 
AnswerRe: Why doesn´t work the Code? Pin
musefan19-Aug-09 23:09
musefan19-Aug-09 23:09 
AnswerRe: Why doesn´t work the Code? Pin
Keith Barrow19-Aug-09 23:10
professionalKeith Barrow19-Aug-09 23:10 

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.