Hello ,
I will rest my publication because the answers that have been proposed does not meet my need
First of all I would like to tell you that
I develop a desktop application c #
I have a form that contains textbox and I have a datagridview and it contains three links
For example I want that when I filled the textbox1 the link 2 and link 3 will be disabled
Here is the code of my form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace gestion_attachements_decomptes
{
public partial class ajouter_decompte : Form
{
string num_marche;
string libelle_fournisseur;
public ajouter_decompte(string num_marche, string libelle_fournisseur)
{
InitializeComponent();
textBox1.Text = num_marche;
textBox2.Text = libelle_fournisseur;
}
private void ajouter_decompte_Load(object sender, EventArgs e)
{
panel2.Visible = false;
dataGridView2.AllowUserToAddRows = false;
DataGridViewLinkColumn link1 = new DataGridViewLinkColumn();
link1.HeaderText = ""; link1.Name = "links1";
link1.Text = "Décompte provisoire";
dataGridView2.Columns.Add(link1);
link1.UseColumnTextForLinkValue = true;
DataGridViewLinkColumn link2 = new DataGridViewLinkColumn();
link2.HeaderText = "";
link2.Name = "links2";
link2.Text = "Décompte partiel";
dataGridView2.Columns.Add(link2);
link2.UseColumnTextForLinkValue = true;
DataGridViewLinkColumn link3 = new DataGridViewLinkColumn();
link3.HeaderText = "";
link3.Name = "links3";
link3.Text = "Décompte définitif";
dataGridView2.Columns.Add(link3);
link3.UseColumnTextForLinkValue = true;
}
private void button1_Click(object sender, EventArgs e)
{
Program.cmd.CommandText =
"update attachement_marche set Id_decompte =
(select top 1 Id_decompte from decompte where Num_decompte ='" + textBox3.Text + "') where Num_attachement = '" + values.num_attachement + "'";
Program.cmd.ExecuteNonQuery();
MessageBox.Show("c'est eneregistré ");
panel2.Visible = true;
Program.cmd.CommandText = " select d.Num_decompte,d.Date_etablissement,d.Flag_dernier,d.Montant_ttc from decompte d WHERE Num_decompte ='" + textBox3.Text + "'";
Program.dr = Program.cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(Program.dr);
dataGridView2.DataSource = dt;
}
private void dataGridView2_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (dataGridView2.SelectedRows.Count == 1)
{ if (dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
{ string cellval = dataGridView2.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
if (cellval.Contains("Décompte provisoire"))
{
etat_decompte_provisoire etd= new etat_decompte_provisoire(textBox1.Text, textBox2.Text);
etd.Show();
}
if (cellval.Contains("Décompte partiel"))
{
decompte_partiel dp = new decompte_partiel(textBox1.Text, textBox2.Text); dp.Show();
}
if (cellval.Contains("Décompte définitif"))
{
decompte_definitif dd = new decompte_definitif(textBox1.Text, textBox2.Text); dd.Show();
}
}
}
}
And I would like to thank everyone who will help me
Madhanmohan DevarajanRank #342 · 7.3K reputationPosted May 17, 2017, 5:56 AM EDT
DataGridViewCellCancelEventArgs e)
{
string msg = String.Format("Editing Cell at ({0}, {1})",
e.ColumnIndex, e.RowIndex);
this.Text = msg;
}
private void dataGridView1_CellEndEdit(object sender,
DataGridViewCellEventArgs e)
{
string msg = String.Format("Finished Editing Cell at ({0}, {1})",
e.ColumnIndex, e.RowIndex);
this.Text = msg;
}
ma oumlRank #3,005 · 479 reputationPosted May 17, 2017, 6:18 AM EDT
Madhanmohan Devarajan
Madhanmohan DevarajanRank #342 · 7.3K reputationPosted May 17, 2017, 6:26 AM EDT
ma oumlRank #3,005 · 479 reputationPosted May 17, 2017, 6:52 AM EDT
Madhanmohan Devarajan
Madhanmohan DevarajanRank #342 · 7.3K reputationPosted May 17, 2017, 8:37 AM EDT
{
if ((textBox1.TextLength > 0) && ((e.ColumnIndex == 1) || (e.ColumnIndex == 2)))
{
e.Cancel = true;
}
}
ma oumlRank #3,005 · 479 reputationPosted May 17, 2017, 9:35 AM EDT
Madhanmohan Devarajan
Madhanmohan DevarajanRank #342 · 7.3K reputationPosted May 17, 2017, 10:04 AM EDT
{
if ((textBox1.TextLength > 0) && ((e.ColumnIndex == 1) || (e.ColumnIndex == 2)))
{
e.Cancel = true;
}
}
ma oumlRank #3,005 · 479 reputationPosted May 17, 2017, 10:15 AM EDT
Madhanmohan Devarajan
ma oumlRank #3,005 · 479 reputationPosted May 17, 2017, 10:19 AM EDT
Madhanmohan DevarajanRank #342 · 7.3K reputationPosted May 17, 2017, 10:28 AM EDT
ma oumlRank #3,005 · 479 reputationPosted May 17, 2017, 10:42 AM EDT
Madhanmohan Devarajan
Madhanmohan DevarajanRank #342 · 7.3K reputationPosted May 17, 2017, 10:51 AM EDT
{
this.dataGridView2.CellBeginEdit += new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.dataGridView2_CellBeginEdit);
}
ma oumlRank #3,005 · 479 reputationPosted May 17, 2017, 10:56 AM EDT
Madhanmohan DevarajanRank #342 · 7.3K reputationPosted May 17, 2017, 11:06 AM EDT
{
if ((dp.textBox1.TextLength > 0) && ((e.ColumnIndex == 1) || (e.ColumnIndex == 2)))
{
e.Cancel = true;
}
}
ma oumlRank #3,005 · 479 reputationPosted May 17, 2017, 11:13 AM EDT
Madhanmohan Devarajan
Madhanmohan DevarajanRank #342 · 7.3K reputationPosted May 17, 2017, 11:27 AM EDT
ma oumlRank #3,005 · 479 reputationPosted May 17, 2017, 11:34 AM EDT
Madhanmohan Devarajan
Madhanmohan DevarajanRank #342 · 7.3K reputationPosted May 17, 2017, 11:43 AM EDT
{
ma oumlRank #3,005 · 479 reputationPosted May 17, 2017, 11:52 AM EDT
Madhanmohan Devarajan
Madhanmohan DevarajanRank #342 · 7.3K reputationPosted May 17, 2017, 12:43 PM EDT
Madhanmohan DevarajanRank #342 · 7.3K reputationPosted May 17, 2017, 12:52 PM EDT
ma oumlRank #3,005 · 479 reputationPosted May 17, 2017, 1:00 PM EDT
Madhanmohan Devarajan
ali tuncerRank #1,499 · 1.1K reputationPosted May 17, 2017, 7:37 PM EDT
Check here for CellContentClick example :
Madhanmohan DevarajanRank #342 · 7.3K reputationPosted May 17, 2017, 7:58 PM EDT
Madhanmohan DevarajanRank #342 · 7.3K reputationPosted May 17, 2017, 12:22 PM EDT
ma oumlRank #3,005 · 479 reputationPosted May 17, 2017, 12:34 PM EDT
ma oumlRank #3,005 · 479 reputationPosted May 17, 2017, 12:49 PM EDT
Madhanmohan Devarajan
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts