MAC
MAC

Reputation: 6577

how to add multiple values?

How i can add the multiple values from a datagrid to textbox in C#? In my project, it includes a datagrid, a textbox and a button.

when the datagrid is populated from the database, the add button will be enable. after that when i click the one entry followed by hitting the add button the selected value will be populated in textbox by seperating a comma. How it will done.

Upvotes: 0

Views: 770

Answers (1)

NitroxDM
NitroxDM

Reputation: 5131

You will need something like this:

on btn click

{
   if(dg.selectedItem != null)
   {
      if (txt.text.length !=0)
      {
        txt.text = txt.text + ", ";
      }
      txt.text = txt.text + dg.selectedItem.text;
   }
}

The dg part is probably wrong it is more likely something like dg.selectedRow[ColName].text.

Now if you decide to add a delete or remove btn you might what to come up with another idea.

Upvotes: 1

Related Questions