Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Pass dynamic datagridview value to textbox

Pass dynamic datagridview value to textbox

Scheduled Pinned Locked Moved C#
databasehelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    asdf23211
    wrote on last edited by
    #1

    I have a code which generated dynamic gridviews based on a column ('c_AnalyticalSystemID"). Now I have a samll problem in passing cell parameter into a textbox which I clicked on a datagridview. the code is : private void button1_Click(object sender, EventArgs e) { string query = "select t.c_AnalyticalSystemID,t.c_RetentionTime,t.c_IonType , t.c_MSstage, k.c_MSstage, t.c_IonFormula, k.c_IonCharge, t.c_IonMass as 'Mass', t.c_MinArea, t.c_UserID_stamp,c_Time_Stamp,k.c_IonTypeRule from C_Analytical_Type1 t join C_AnalyticalSystems c on t.c_analyticalsystemid = c. c_analyticalsystemid join C_Analytical_Type1_IonTypes k on k.c_iontype = t.c_iontype where t.c_id=" + Convert.ToInt32(textBox1.Text.ToString()) + ""; DataTable dt_cmbo_ = new DataTable(); OdbcDataAdapter cmbo_ = new OdbcDataAdapter("SELECT c_IonCharge,c_IonType,c_IonTypeExplained from C_Analytical_Type1_IonTypes", OdbcCon); dt_cmbo_.Columns.Clear(); dt_cmbo_.Rows.Clear(); cmbo_.Fill(dt_cmbo_); OdbcCommand cmd = new OdbcCommand(query, OdbcCon); OdbcDataReader dr = cmd.ExecuteReader(); DataTable dt1 = new DataTable(); dt1.Load(dr); int margin = 30; Point pt = new Point(margin, margin); panel1.Controls.Clear(); DataTable distinctSystemIDs = dt1.DefaultView.ToTable(true, "c_AnalyticalSystemID"); // DataTable ion = dt.DefaultView.ToTable(true, "c_IonTypeExplained"); for (int i = 0; i <= distinctSystemIDs.Rows.Count -1; i++) { int systemID = (int)distinctSystemIDs.Rows[i][0]; DataGridView dgw = new DataGridView(); Label l = new Label(); l.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; l.Location = pt; l.Text = "System " + systemID.ToString(); pt.Y += l.Height + 2; // margin is for spacing between grids dgw.Tag = systemID; // store systemID of the DGV if you need it later dgw.AllowUserToAddRows = false; dgw.AllowUserToDeleteRows = false; dgw.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; dgw.Size = new Size(730, 100); // 2 * margin = left + right margin dgw.Location = pt;

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups