Click here to Skip to main content
15,908,931 members
Home / Discussions / C#
   

C#

 
QuestionSetup app, with single progress dialog. Pin
David Hovey22-May-10 4:34
David Hovey22-May-10 4:34 
AnswerRe: Setup app, with single progress dialog. Pin
Abhinav S22-May-10 4:56
Abhinav S22-May-10 4:56 
AnswerRe: Setup app, with single progress dialog. Pin
DaveyM6922-May-10 5:06
professionalDaveyM6922-May-10 5:06 
AnswerRe: Setup app, with single progress dialog. Pin
Not Active22-May-10 5:34
mentorNot Active22-May-10 5:34 
QuestionInserting multiple IDs in Items table but the same ID should go into MasterRequest table just once. Pin
Omar Akhtar 200922-May-10 3:01
Omar Akhtar 200922-May-10 3:01 
Questionxml to gridview Pin
Tomlor198022-May-10 2:49
Tomlor198022-May-10 2:49 
AnswerRe: xml to gridview [Repost] Pin
Richard MacCutchan22-May-10 4:30
mveRichard MacCutchan22-May-10 4:30 
QuestionPass dynamic datagridview value to textbox Pin
asdf2321122-May-10 1:24
asdf2321122-May-10 1:24 
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;
pt.Y += dgw.Height + margin; // margin is for spacing between grids
//this.Controls.Add(dgw);
// dgw.Columns["c_IonTypeRule"].Visible = false;
//dgw.Columns["c_AnalyticalTypeExplained"].Visible = false;
// dgw.Columns["c_ID"].Visible = false;

cmdx.Name = "IonType";
cmdx.DataPropertyName = "c_IonType";
cmdx.HeaderText = "IonType";
cmdx.Width = 80;
cmdx.DataSource = dt_cmbo_;
cmdx.ValueMember = "c_IonType";
cmdx.DisplayMember = "c_IonTypeExplained";
//c_IonTypeRule cmdx.DisplayMember = " c_IonCharge";
panel1.Controls.Add(dgw);
panel1.Controls.Add(l);
dgw.Columns.Add(cmdx);
DataView vw = new DataView(dt1, string.Format("c_AnalyticalSystemID = {0}", systemID), null, DataViewRowState.CurrentRows);
dgw.DataSource = vw;
dgw.Columns["c_AnalyticalSystemID"].ReadOnly = true;

// dgw.Rows[i].Cells["IonCharge"].Value = textBox1.Text;
dgw.Columns[3].Visible = false;
int k = 0;




}

}



private void dgw_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
try
{
DataGridViewRow row = new DataGridViewRow();
//DataGridView dgw = new DataGridView();
row = dgw.Rows[e.RowIndex];
// d2 = 1;
// Will put the value of the first column of the selected row into the textbox
textBox60.Text = row.Cells[e.ColumnIndex].Value.ToString();
}
Is it correct what I'm doing to get the value of cell into a textbox when clicked on a paticular datagridview.

The main aim was to edit a record and my head wants to have a single button, so I thought of passing values to textboxs which they want to edit by clicking on that record of that gridview generated automatically. Can you give me an idea how to do this or is there any other way?
Srikanth

QuestionCode Quality Check Pin
Chiman122-May-10 1:06
Chiman122-May-10 1:06 
AnswerRe: Code Quality Check Pin
Abhinav S22-May-10 1:13
Abhinav S22-May-10 1:13 
AnswerRe: Code Quality Check Pin
Łukasz Nowakowski22-May-10 1:35
Łukasz Nowakowski22-May-10 1:35 
GeneralRe: Code Quality Check Pin
Khaniya22-May-10 2:29
professionalKhaniya22-May-10 2:29 
QuestionWindows Forms inheritance problem Pin
Łukasz Nowakowski22-May-10 0:02
Łukasz Nowakowski22-May-10 0:02 
AnswerRe: Windows Forms inheritance problem Pin
Rob Smiley22-May-10 1:23
Rob Smiley22-May-10 1:23 
GeneralRe: Windows Forms inheritance problem Pin
Łukasz Nowakowski22-May-10 1:26
Łukasz Nowakowski22-May-10 1:26 
Questionclear history in browser Pin
Rajeshwar Code- Developer21-May-10 23:21
Rajeshwar Code- Developer21-May-10 23:21 
AnswerRe: clear history in browser Pin
Abhinav S22-May-10 0:26
Abhinav S22-May-10 0:26 
QuestionAbout Keyword in .NET Pin
Isaac Gordon21-May-10 22:12
Isaac Gordon21-May-10 22:12 
AnswerRe: About Keyword in .NET Pin
DaveyM6921-May-10 22:54
professionalDaveyM6921-May-10 22:54 
AnswerRe: About Keyword in .NET Pin
OriginalGriff21-May-10 23:07
mveOriginalGriff21-May-10 23:07 
GeneralRe: About Keyword in .NET Pin
Isaac Gordon21-May-10 23:21
Isaac Gordon21-May-10 23:21 
GeneralRe: About Keyword in .NET Pin
Pete O'Hanlon21-May-10 23:58
mvePete O'Hanlon21-May-10 23:58 
GeneralRe: About Keyword in .NET Pin
OriginalGriff22-May-10 0:09
mveOriginalGriff22-May-10 0:09 
GeneralRe: About Keyword in .NET Pin
harold aptroot22-May-10 0:24
harold aptroot22-May-10 0:24 
GeneralRe: About Keyword in .NET Pin
OriginalGriff22-May-10 0:35
mveOriginalGriff22-May-10 0:35 

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.