473,230 Members | 1,594 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,230 software developers and data experts.

Data Grid View doen't hide the first column!

this is something really i can't find a reason. I have a form with a
tabcontrol with tree pages, in the second page there is a Data GRid View.
Plus i have a class. When i open the form i "inizialize" the Data Grid View
(add a data sorce, filled with notthing at staratup, and hide some columns)
when i put a code in the txtCLCOD textbox start a searsh. If i foud
something i popolate the Data grid view on the second page. Now the magic if
i select the second page containig the dgv first to make the search all the
columns i select to hide will be hidden, if i start the serach withhout
going on the second page a colum that i hidden is visible!!!! the colum is
the frst colum!!!!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Interventi.Business;

namespace Interventi.Client.Forms
{
public partial class frmClienti : Form
{
clsClienti clsClienti = new clsClienti();

public frmClienti()
{
InitializeComponent();
}

private void PopolaCampi()
{
txtSEVIA.Text =
dgvSEDI.SelectedRows[0].Cells[5].Value.ToString();
txtSECAP.Text =
dgvSEDI.SelectedRows[0].Cells[6].Value.ToString();
txtSECOMU.Text =
dgvSEDI.SelectedRows[0].Cells[7].Value.ToString();
txtSEPROV.Text =
dgvSEDI.SelectedRows[0].Cells[8].Value.ToString();
txtSETEL1.Text =
dgvSEDI.SelectedRows[0].Cells[9].Value.ToString();
txtSETEL2.Text =
dgvSEDI.SelectedRows[0].Cells[10].Value.ToString();
txtSEFAX.Text =
dgvSEDI.SelectedRows[0].Cells[11].Value.ToString();
txtSEPERS.Text =
dgvSEDI.SelectedRows[0].Cells[12].Value.ToString();
txtSEPERC.Text =
dgvSEDI.SelectedRows[0].Cells[13].Value.ToString();
txtSEPERM.Text =
dgvSEDI.SelectedRows[0].Cells[14].Value.ToString();
}

private void CreaArraydiTextBox(TextBox[] txtTextBox)
{
//UTCOD
//CLULMO
txtTextBox.SetValue(txtCLCOD, 0);
txtTextBox.SetValue(txtCLRAGS, 1);
txtTextBox.SetValue(txtCLPIVA, 2);
//ISCOD
txtTextBox.SetValue(txtCLVIA, 3);
txtTextBox.SetValue(txtCLCAP, 4);
txtTextBox.SetValue(txtCLCOMU, 5);
txtTextBox.SetValue(txtCLPROV, 6);
txtTextBox.SetValue(txtCLTEL1, 7);
txtTextBox.SetValue(txtCLTEL2, 8);
txtTextBox.SetValue(txtCLFAX, 9);
txtTextBox.SetValue(txtCLWWW, 10);
txtTextBox.SetValue(txtCLMAIL, 11);
txtTextBox.SetValue(txtCLPERS, 12);
txtTextBox.SetValue(txtCLPERC, 13);
txtTextBox.SetValue(txtCLPERM, 14);
//TPCOD
//PGCOD
//SSCOD
txtTextBox.SetValue(txtCLNOTE, 15);
}

private void CreaArraydiCombo(ComboBox[] cboCombo)
{
cboCombo.SetValue(cboTPCOD, 0);
cboCombo.SetValue(cboSSCOD, 1);
cboCombo.SetValue(cboPGCOD, 2);
}

private void toolStripButton7_Click(object sender, EventArgs e)
{

this.Close();

}

private void toolStripButton5_Click(object sender, EventArgs e)
{
frmClientiRic frmClRic = new frmClientiRic();
frmClRic.ShowDialog();
}

private void button2_Click(object sender, EventArgs e)
{
frmComuni frmComuni = new frmComuni();
frmComuni.ShowDialog();
}

private void button1_Click(object sender, EventArgs e)
{
frmComuni frmComuni = new frmComuni();
frmComuni.ShowDialog();
}

private void cLPROVTextBox_TextChanged(object sender, EventArgs e)
{

}

private void frmClienti_Load(object sender, EventArgs e)
{
ComboBox[] cboCombo = new ComboBox[3];
CreaArraydiCombo(cboCombo);
clsClienti.PopolaCombo(cboCombo);
txtCLCOD.Focus();

clsClienti.InizializiaGrid(dgvSEDI);

}

private void txtCLCOD_Leave(object sender, EventArgs e)
{
bool blnRicerca;
TextBox[] txtTextBox = new TextBox[16];
ComboBox[] cbocombo = new ComboBox[3];

txtCLCOD.Text = txtCLCOD.Text.Trim().ToUpper();
if (txtCLCOD.Text.Trim() != "")
{
blnRicerca =
clsClienti.EseguiRicerca(txtCLCOD.Text.Trim().ToUp per());
if (blnRicerca == true)
{
CreaArraydiTextBox(txtTextBox);
CreaArraydiCombo(cbocombo);
clsClienti.PopolaCampi(txtTextBox);
clsClienti.SettaCombo(cbocombo,
txtCLCOD.Text.Trim().ToUpper());
clsClienti.PopolaSedi(dgvSEDI,
txtCLCOD.Text.Trim().ToUpper());
if (dgvSEDI.Rows.Count >= 1)
{
PopolaCampi();
}

}
}
}

private void button3_Click(object sender, EventArgs e)
{
frmClientiTipo frmTPCli = new frmClientiTipo();
frmTPCli.ShowDialog();
}

private void button4_Click(object sender, EventArgs e)
{
frmTecnici frmTecnici = new frmTecnici();
frmTecnici.ShowDialog();
}

private void button5_Click(object sender, EventArgs e)
{
FrmModPag frmModPag = new FrmModPag();
frmModPag.ShowDialog();
}

private void dgvSEDI_SelectionChanged(object sender, EventArgs e)
{
//se non imposto questo if ogni volta che al load la clsasse
clsutenti nasconde una colonna parte questo evento

if (dgvSEDI.Rows.Count 1 & dgvSEDI.Columns[0].Visible ==
false)

{

PopolaCampi();
}

}
}
}




using System;
using System.Collections.Generic;
using System.Data;
using System.Windows.Forms;
using Interventi.Data;
using Interventi.Data.dsInterventiTableAdapters;

namespace Interventi.Business
{
public class clsClienti
{
dsInterventi dsInterventi = new dsInterventi();
CLIENTITableAdapter taClienti = new CLIENTITableAdapter();
BindingSource bdnClienti = new BindingSource();
BindingSource bdnSedi = new BindingSource();
TPCLITableAdapter taTPcli = new TPCLITableAdapter();
SYSTEMTableAdapter taSystem = new SYSTEMTableAdapter();
MODPAGTableAdapter taModPag = new MODPAGTableAdapter();
SEDETableAdapter taSede = new SEDETableAdapter();

public void InizializiaGrid(DataGridView DGV)
{
taSede.FillByCLCOD(dsInterventi.SEDE, "");
bdnSedi.DataSource = dsInterventi;
bdnSedi.DataMember = "SEDE";
DGV.DataSource = bdnSedi;

/*
UTCOD
SEULMO
SEPROG
CLCOD
ISCOD
SEVIA
SECAP
SECOMU
SEPROV
SETEL1
SETEL2
SEFAX
SEPERS
SEPERC
SEPERM
*/

DGV.Columns["UTCOD"].Visible = false;
DGV.Columns["SEULMO"].Visible = false;
DGV.Columns["SEPROG"].Visible = false;
DGV.Columns["CLCOD"].Visible = false;
DGV.Columns["ISCOD"].Visible = false;
DGV.Columns["CLCOD"].Visible = false;
DGV.Columns["SETEL1"].Visible = false;
DGV.Columns["SETEL2"].Visible = false;
DGV.Columns["SEFAX"].Visible = false;
DGV.Columns["SEPERS"].Visible = false;
DGV.Columns["SEPERC"].Visible = false;
DGV.Columns["SEPERM"].Visible = false;

DGV.Columns["SEVIA"].Width = 250;
DGV.Columns["SEVIA"].HeaderText = "Via";
DGV.Columns["SECAP"].Width = 50;
DGV.Columns["SECAP"].HeaderText = "CAP";
DGV.Columns["SECOMU"].Width = 100;
DGV.Columns["SECOMU"].HeaderText = "Comune";
DGV.Columns["SEPROV"].Width = 40;
DGV.Columns["SEPROV"].HeaderText = "Prov";
}

public bool EseguiRicerca(string strCLCOD)
{
taClienti.FillByclCod(dsInterventi.CLIENTI, strCLCOD);
if (dsInterventi.CLIENTI.Rows.Count 0) return true;
else return false;
}

public void PopolaCombo(ComboBox[] cboCombo)
{
taTPcli.Fill(dsInterventi.TPCLI);
DataTableReader dtrTPCli = new
DataTableReader(dsInterventi.TPCLI);
//dtrTPCli.Read();
cboCombo[0].Items.Add("Selezionare un Tipo Cliente..");
while (dtrTPCli.Read())
{
clsCombo combo = new clsCombo();
combo.Add(dtrTPCli[3].ToString(), dtrTPCli[2].ToString());
cboCombo[0].Items.Add(combo);
}
cboCombo[0].SelectedIndex = 0;

taSystem.Fill(dsInterventi.SYSTEM);
DataTableReader dtrSystem = new
DataTableReader(dsInterventi.SYSTEM);
cboCombo[1].Items.Add("Selezionare un Tecnico..");
while (dtrSystem.Read())
{
clsCombo combo = new clsCombo();
combo.Add(dtrSystem[3].ToString() + " " +
dtrSystem[4].ToString(),dtrSystem[2].ToString());
cboCombo[1].Items.Add(combo);
}
cboCombo[1].SelectedIndex = 0;

taModPag.Fill(dsInterventi.MODPAG);
DataTableReader dstModPag = new
DataTableReader(dsInterventi.MODPAG);
cboCombo[2].Items.Add("Selezionare una Modalità di
Pagamento..");
while (dstModPag.Read())
{
clsCombo combo = new clsCombo();
combo.Add(dstModPag[3].ToString(), dstModPag[2].ToString());
cboCombo[2].Items.Add(combo);
}
cboCombo[2].SelectedIndex = 0;

}

public void SettaCombo(ComboBox[] cboCombo, string strCLCOD)
{
//taClienti.FillByclCod(dsInterventi.CLIENTI, strCLCOD);
dsInterventi.CLIENTIRow rowCliente;
rowCliente = dsInterventi.CLIENTI.FindByCLCOD(strCLCOD);

if (cboCombo[0].Items.Count 0)
{
for (int i = 1; i < cboCombo[0].Items.Count; i++)
{
if (rowCliente.TPCOD ==
((clsCombo)cboCombo[0].Items[i]).strNomeColnna)
{
cboCombo[0].SelectedIndex = i;
break;
}
}
}

if (cboCombo[1].Items.Count 0)
{
for (int i = 1; i < cboCombo[1].Items.Count; i++)
{
if (rowCliente.SSCOD ==
((clsCombo)cboCombo[1].Items[i]).strNomeColnna)
{
cboCombo[1].SelectedIndex = i;
break;
}
}
}

if (cboCombo[2].Items.Count 0)
{
for (int i = 1; i < cboCombo[2].Items.Count; i++)
{
if (rowCliente.PGCOD ==
((clsCombo)cboCombo[2].Items[i]).strNomeColnna)
{
cboCombo[2].SelectedIndex = i;
break;
}
}
}
}

public void PopolaCampi(TextBox[] txtTextbox)
{
dsInterventi.CLIENTIRow rowCliente;
rowCliente =
dsInterventi.CLIENTI.FindByCLCOD(txtTextbox[0].Text);

txtTextbox[0].Enabled = false;
txtTextbox[1].Text = rowCliente.CLRAGS;
txtTextbox[2].Text = rowCliente.CLPIVA;
txtTextbox[3].Text = rowCliente.CLVIA;
txtTextbox[4].Text = rowCliente.CLCAP;
txtTextbox[5].Text = rowCliente.CLCOMU;
txtTextbox[6].Text = rowCliente.CLPROV;
txtTextbox[7].Text = rowCliente.CLTEL1;
txtTextbox[8].Text = rowCliente.CLTEL2;
txtTextbox[9].Text = rowCliente.CLFAX;
txtTextbox[10].Text = rowCliente.CLWWW;
txtTextbox[11].Text = rowCliente.CLMAIL;
txtTextbox[12].Text = rowCliente.CLPERS;
txtTextbox[13].Text = rowCliente.CLPERC;
txtTextbox[14].Text = rowCliente.CLPERM;
txtTextbox[15].Text = rowCliente.CLNOTE;


//DataTableReader dtrUtenti = new
DataTableReader(dsInterventi.UTENTI);
//dtrUtenti.Read();
}

public void PopolaSedi(DataGridView DGV, string strUTCOD)
{
try
{
if (DGV.DataSource == null) InizializiaGrid(DGV);
taSede.FillByCLCOD(dsInterventi.SEDE, strUTCOD);
}
catch (Exception e)
{
throw new System.ArgumentException(e.Message.ToString(),
"clsClienti PopolaGrid");
}
}

}
}


Aug 4 '06 #1
0 4129

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: pmud | last post by:
Hi, I need to display columns in a data grid based on 7 different queries. Now I have 32 questions: 1. Is it possble to have 1 single data adapter with 7 queries & 1 data set or do I need to...
12
by: pmud | last post by:
Hi, I am using teh following code for sorting the data grid but it doesnt work. I have set the auto generate columns to false. & set the sort expression for each field as the anme of that...
6
by: Mike Kirkpatrick | last post by:
I have this data grid which consists of 3 pick lists. The first pick list is to affect the data binding of the other two. I have figured out how to do the data binding by column. However, I do not...
15
by: John Blair | last post by:
Hi, Code attached but the line that gives me an error is MyDataGrid.Columns(2).Visible = False It actually gives me an error for any value instead of 2 even when 9 bound columns of data exist....
2
by: Joe Griffith | last post by:
I'm using a Win Forms Data Grid View control in unbound mode. When I add columns using the wizard the first item is the column name. Everything works fine. However, if you return to the...
2
by: =?Utf-8?B?Z2FuZQ==?= | last post by:
Hi, In a gridview, How can i display different columns between item and edit modes. For eg. i have a sql that returns productname, categoryname, etc. In viewmode, i need to display only...
7
by: RolfHerbert | last post by:
Hi all, Source code below. I am using an sqldatasorce to populate a datagrid. I am using datakeyIds. I am interested in two keys which I have added to the datakeyids, however if either of the...
0
by: zafar | last post by:
I don't know what property should be used for hiding colums in Data Grid, whereas in Data Grid View we have DataGridView1.Colums(index).Visible = False , But how can I hide Colums in Data Grid.....
6
by: insirawali | last post by:
Hi all, I have this problem, i need to know is there a way i cn use the data adapter's update method in this scenario. i have 3 tables as below create table table1{ id1 int identity(1,1)...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.