Evitar expandir Node ao clicar no sinal [+]Pessoal, Meu pedido é simples mas não consegui encontrar no forum.<br/>Como evitar que os meus nodes, sejam Root ou não, se expandam quando o usuário clicar no sinal de [+] que se encontram a esquerda de cada node?<br/>Usei este código <span style="font-size:x-small">dbTview.ShowRootLines = </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">false</span></span><span style="font-size:x-small">;, mas apenas escondeu o sinal de [+] do Root.<br/><br/>Agradecido.<br/>Airton Barros<br/></span><hr class="sig">JOAB© 2009 Microsoft Corporation. Todos os direitos reservados.Wed, 01 Apr 2009 23:07:48 Z990afef6-7d9f-42d1-adbd-2ad36fb76a7fhttp://social.msdn.microsoft.com/Forums/pt-BR/vscsharppt/thread/990afef6-7d9f-42d1-adbd-2ad36fb76a7f#990afef6-7d9f-42d1-adbd-2ad36fb76a7fhttp://social.msdn.microsoft.com/Forums/pt-BR/vscsharppt/thread/990afef6-7d9f-42d1-adbd-2ad36fb76a7f#990afef6-7d9f-42d1-adbd-2ad36fb76a7fJOAB_ARAUJOhttp://social.msdn.microsoft.com/Profile/pt-BR/?user=JOAB_ARAUJOEvitar expandir Node ao clicar no sinal [+]Pessoal, Meu pedido é simples mas não consegui encontrar no forum.<br/>Como evitar que os meus nodes, sejam Root ou não, se expandam quando o usuário clicar no sinal de [+] que se encontram a esquerda de cada node?<br/>Usei este código <span style="font-size:x-small">dbTview.ShowRootLines = </span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">false</span></span><span style="font-size:x-small">;, mas apenas escondeu o sinal de [+] do Root.<br/><br/>Agradecido.<br/>Airton Barros<br/></span><hr class="sig">JOABSat, 28 Mar 2009 17:47:48 Z2009-03-28T17:47:48Zhttp://social.msdn.microsoft.com/Forums/pt-BR/vscsharppt/thread/990afef6-7d9f-42d1-adbd-2ad36fb76a7f#0287a213-276b-4963-889a-c86a0329d7d6http://social.msdn.microsoft.com/Forums/pt-BR/vscsharppt/thread/990afef6-7d9f-42d1-adbd-2ad36fb76a7f#0287a213-276b-4963-889a-c86a0329d7d6AndreAlvesLimahttp://social.msdn.microsoft.com/Profile/pt-BR/?user=AndreAlvesLimaEvitar expandir Node ao clicar no sinal [+]Prezado, <br/><br/>Como assim? Você quer evitar que a TreeView expanda?<hr class="sig">André Alves de Lima - http://andrealveslima.spaces.live.comMon, 30 Mar 2009 11:52:36 Z2009-03-30T11:52:36Zhttp://social.msdn.microsoft.com/Forums/pt-BR/vscsharppt/thread/990afef6-7d9f-42d1-adbd-2ad36fb76a7f#23c73f2d-9eee-4efa-8394-2216c0596969http://social.msdn.microsoft.com/Forums/pt-BR/vscsharppt/thread/990afef6-7d9f-42d1-adbd-2ad36fb76a7f#23c73f2d-9eee-4efa-8394-2216c0596969JOAB_ARAUJOhttp://social.msdn.microsoft.com/Profile/pt-BR/?user=JOAB_ARAUJOEvitar expandir Node ao clicar no sinal [+]Olá André.<br/>Quero que o Node se expanda apenas quando der o duplo click no texto do Node e não quando clicar no sinal de [+], por isso solicito um código que anule a ação de expandir o node quando clicar no sinal de [+].<br/><br/>Agradecido.<br/>Airton<hr class="sig">JOABMon, 30 Mar 2009 23:28:01 Z2009-03-30T23:28:01Zhttp://social.msdn.microsoft.com/Forums/pt-BR/vscsharppt/thread/990afef6-7d9f-42d1-adbd-2ad36fb76a7f#75a4a5d5-bc3b-4586-a38e-62c760d6aa61http://social.msdn.microsoft.com/Forums/pt-BR/vscsharppt/thread/990afef6-7d9f-42d1-adbd-2ad36fb76a7f#75a4a5d5-bc3b-4586-a38e-62c760d6aa61AndreAlvesLimahttp://social.msdn.microsoft.com/Profile/pt-BR/?user=AndreAlvesLimaEvitar expandir Node ao clicar no sinal [+]<p>Nossa, que interessante... Nunca ví ninguém querer fazer isso, mas, enfim, vamos lá... Hehehe...<br/><br/>Consegui fazer aqui da seguinte maneira (não sei se tem um modo mais fácil... procurei na internet e não consegui achar...): <br/><br/>- Criei um atributo no form chamado _doubleClick, que vai estar sempre setado como falso, a não ser que um nó seja clicado duplamente;<br/>- Implementei o evento DoubleClick do TreeView para setar o atributo _doubleClick do form como true e chamar o Expand do nó;<br/>- Implementei o evento BeforeExpand do TreeView para verificar se o atributo _doubleClick do form está true. Se sim, volta o atributo para false e expande o nó normalmente. Se não, cancela o evento de expand.<br/><br/>Com isso, o resultado foi o seguinte (código de um form com um TreeView, chamado treeview1):<br/></p> <pre lang="x-c#"> public partial class Form8 : Form { private bool _doubleClick = false; public Form8() { InitializeComponent(); } private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e) { if (!_doubleClick.Equals(true)) e.Cancel = true; else _doubleClick = false; } private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { _doubleClick = true; e.Node.Expand(); } }</pre><hr class="sig">André Alves de Lima - http://andrealveslima.spaces.live.comTue, 31 Mar 2009 11:52:37 Z2009-03-31T11:52:37Zhttp://social.msdn.microsoft.com/Forums/pt-BR/vscsharppt/thread/990afef6-7d9f-42d1-adbd-2ad36fb76a7f#99de8b0a-c585-4e04-9b7a-0ea19a4751e9http://social.msdn.microsoft.com/Forums/pt-BR/vscsharppt/thread/990afef6-7d9f-42d1-adbd-2ad36fb76a7f#99de8b0a-c585-4e04-9b7a-0ea19a4751e9JOAB_ARAUJOhttp://social.msdn.microsoft.com/Profile/pt-BR/?user=JOAB_ARAUJOEvitar expandir Node ao clicar no sinal [+]Olá André.<br/>Muito obrigado e marcarei a reposta como válida.<br/><br/>Explicação do Pedido.<br/>=================<br/>André, meu problema é que estou populando a treeview com 06 tabelas com JOIN e habilitando abas de tabcontrol usando como parâmetro o texto do node, até usei o evento NodeMouseClick, funcionou com o 1º nível e os outros níveis, mas não funciona com o 2º nível, não sei porque!, e única solução que achei foi esta, que voçê m respondeu.<br/><br/>Eis o código para popular a treeview.<br/> <pre lang="x-c#">public void CarregaTreeView() { int indexSafra = 0; int indexFaz = 0; int indexTalhao = 0; int indexMovimentos = 0; int indexInsumos = 0; int indexHrMaquina = 0; dbTview.BeginUpdate(); dbTview.Nodes.Clear(); StringBuilder Sql = new StringBuilder(); Sql.Append(&quot;SELECT S.SAFRA_SAFRA, F.ID_FUNDO_AGRIC_FAZ, F.DESC_FUNDO_AGRIC_FZ, T.ID_TALHAO_TALHAO,&quot;); Sql.Append(&quot; MT.COD_ATIVIDADE_CTALHAO, MT.DESC_ATIVIDADE_CT, MT.DATA_LANCAMENTO_CTALHAO, I.DESC_PRODUTO_INS,&quot;); Sql.Append(&quot; I.DOSAGEM_APLICADA_INS, M.ID_MAQUINA, M.DESC_MAQUINA_MQ&quot;); Sql.Append(&quot; FROM TB_PRINC_CUSTO_SAFRA S&quot;); Sql.Append(&quot; LEFT JOIN TB_PRINC_CUSTO_FAZENDAS F&quot;); Sql.Append(&quot; ON S.SAFRA_SAFRA=F.SAFRA_FAZ&quot;); Sql.Append(&quot; LEFT JOIN TB_PRINC_CUSTO_FAZ_TALHOES T&quot;); Sql.Append(&quot; ON F.SAFRA_FAZ=T.SAFRA_TALHOES&quot;); Sql.Append(&quot; AND F.ID_FUNDO_AGRIC_FAZ=T.ID_FUNDO_AGRIC_TALHOES&quot;); Sql.Append(&quot; LEFT JOIN TB_PRINC_CUSTO_TALHAO MT&quot;); Sql.Append(&quot; ON T.SAFRA_TALHOES=MT.SAFRA_CTALHAO&quot;); Sql.Append(&quot; AND T.ID_FUNDO_AGRIC_TALHOES=MT.ID_FUNDO_AGRIC_CTALHAO&quot;); Sql.Append(&quot; AND T.ID_TALHAO_TALHAO=MT.ID_TALHAO_CTALHAO&quot;); Sql.Append(&quot; LEFT JOIN TB_CUSTO_TALHAO_UNSUMOS I&quot;); Sql.Append(&quot; ON MT.SAFRA_CTALHAO=I.SAFRA_INS&quot;); Sql.Append(&quot; AND MT.ID_FUNDO_AGRIC_CTALHAO=I.ID_FUNDO_AGRIC_INS&quot;); Sql.Append(&quot; AND MT.ID_TALHAO_CTALHAO=I.ID_TALHAO_INS&quot;); Sql.Append(&quot; AND MT.DATA_LANCAMENTO_CTALHAO=I.DATA_LANCAMENTO_INS&quot;); Sql.Append(&quot; AND MT.COD_ATIVIDADE_CTALHAO=I.COD_ATIVIDADE_INS&quot;); Sql.Append(&quot; LEFT JOIN TB_CUSTO_TALHAO_MAQUINAS M&quot;); Sql.Append(&quot; ON MT.SAFRA_CTALHAO=M.SAFRA_MAQ&quot;); Sql.Append(&quot; AND MT.ID_FUNDO_AGRIC_CTALHAO=M.ID_FUNDO_AGRIC_MAQ&quot;); Sql.Append(&quot; AND MT.ID_TALHAO_CTALHAO=M.ID_TALHAO_MAQ&quot;); Sql.Append(&quot; AND MT.DATA_LANCAMENTO_CTALHAO=M.DATA_LANCAMENTO_MAQ&quot;); Sql.Append(&quot; AND MT.COD_ATIVIDADE_CTALHAO=M.COD_ATIVIDADE_MAQ&quot;); /*Sql.Append(&quot; LEFT JOIN TB_CUSTO_TALHAO_MAO_DE_OBRA O&quot;); Sql.Append(&quot; ON MT.SAFRA_CTALHAO=O.SAFRA_MOB&quot;); Sql.Append(&quot; AND MT.ID_FUNDO_AGRIC_CTALHAO=O.ID_FUNDO_AGRIC_MOB&quot;); Sql.Append(&quot; AND MT.ID_TALHAO_CTALHAO=O.ID_TALHAO_MOB&quot;); Sql.Append(&quot; AND MT.DATA_LANCAMENTO_CTALHAO=O.DATA_LANCAMENTO_MOB&quot;); Sql.Append(&quot; AND MT.COD_ATIVIDADE_CTALHAO=O.COD_ATIVIDADE_MOB&quot;); */ FbCommand cmdCusteio = new FbCommand(Sql.ToString(), ConnFb); FbDataReader drCusteio; drCusteio = cmdCusteio.ExecuteReader(); TreeNode noSafra; TreeNode noGrpFaz; TreeNode noFazendas; TreeNode noGrpTalhoes; TreeNode noTalhoes; TreeNode noGrpMov; TreeNode noMovimentos; TreeNode noGrpInsumos; TreeNode noInsumos; TreeNode noHrMaquinas; TreeNode noGrpMaq; string sgnSafra = string.Empty; string sgnFazendas = string.Empty; string sgnTalhoes = string.Empty; string sgnMovimentos = string.Empty; string sgnInsumos = string.Empty; string sgnServico = string.Empty; string sgnNomesProdutos = string.Empty; string sgnHrMaquina = string.Empty; while (drCusteio.Read()) { if (!((string)drCusteio[&quot;SAFRA_SAFRA&quot;].ToString() == sgnSafra)) { noSafra = new TreeNode(); noSafra.ImageIndex = 0; noSafra.Tag = &quot;Safra&quot;; noSafra.Text = drCusteio[&quot;SAFRA_SAFRA&quot;].ToString(); dbTview.Nodes.Add(noSafra); indexSafra = noSafra.Index; sgnSafra = drCusteio[&quot;SAFRA_SAFRA&quot;].ToString(); noGrpFaz = new TreeNode(); noGrpFaz.Tag = string.Empty; noGrpFaz.BackColor = Color.Bisque; noGrpFaz.ForeColor = Color.Brown; noGrpFaz.Text = &quot;FAZENDAS&quot;; dbTview.Nodes[indexSafra].Nodes.Add(noGrpFaz); } if (!((string)drCusteio[&quot;ID_FUNDO_AGRIC_FAZ&quot;].ToString() == sgnFazendas)) { noFazendas = new TreeNode(); noFazendas.ImageIndex = 1; noFazendas.Tag = &quot;Fazendas&quot;; noFazendas.Text = Convert.ToInt32(drCusteio[&quot;ID_FUNDO_AGRIC_FAZ&quot;]).ToString(&quot;00&quot;) + &quot;-&quot; + drCusteio[&quot;DESC_FUNDO_AGRIC_FZ&quot;].ToString(); dbTview.Nodes[indexSafra].Nodes.Add(noFazendas); indexFaz = noFazendas.Index; sgnFazendas = drCusteio[&quot;ID_FUNDO_AGRIC_FAZ&quot;].ToString(); noGrpTalhoes = new TreeNode(); noGrpTalhoes.Tag = string.Empty; noGrpTalhoes.BackColor = Color.AliceBlue; noGrpTalhoes.ForeColor = Color.Blue; noGrpTalhoes.Text = &quot;TALHÕES&quot;; dbTview.Nodes[indexSafra].Nodes[indexFaz].Nodes.Add(noGrpTalhoes); } if (!((string)drCusteio[&quot;ID_TALHAO_TALHAO&quot;].ToString() == sgnTalhoes)) { noTalhoes = new TreeNode(); noTalhoes.ImageIndex = 1; noTalhoes.Tag = &quot;Talhoes&quot;; noTalhoes.Text = Convert.ToInt32(drCusteio[&quot;ID_TALHAO_TALHAO&quot;]).ToString(&quot;00&quot;); dbTview.Nodes[indexSafra].Nodes[indexFaz].Nodes.Add(noTalhoes); indexTalhao = noTalhoes.Index; sgnTalhoes = drCusteio[&quot;ID_TALHAO_TALHAO&quot;].ToString(); noGrpMov = new TreeNode(); noGrpMov.Tag = string.Empty; noGrpMov.BackColor = Color.AliceBlue; noGrpMov.ForeColor = Color.Green; noGrpMov.Text = &quot;MOVIMENTOS&quot;; dbTview.Nodes[indexSafra].Nodes[indexFaz].Nodes[indexTalhao].Nodes.Add(noGrpMov); } if (drCusteio[&quot;COD_ATIVIDADE_CTALHAO&quot;] != null) { if (!((string)drCusteio[&quot;DESC_ATIVIDADE_CT&quot;].ToString() == sgnMovimentos)) { noMovimentos = new TreeNode(); noMovimentos.ImageIndex = 1; noMovimentos.Tag = &quot;Movimentos&quot;; noMovimentos.Text = string.Format(&quot;{0:dd/MM/yyy}&quot;, drCusteio[&quot;DATA_LANCAMENTO_CTALHAO&quot;]).ToString() + &quot;-&quot; + string.Format(&quot;{0:00}&quot;, drCusteio[&quot;COD_ATIVIDADE_CTALHAO&quot;]) + &quot;-&quot; + drCusteio[&quot;DESC_ATIVIDADE_CT&quot;].ToString(); dbTview.Nodes[indexSafra].Nodes[indexFaz].Nodes[indexTalhao].Nodes.Add(noMovimentos); indexMovimentos = noMovimentos.Index; sgnMovimentos = drCusteio[&quot;DESC_ATIVIDADE_CT&quot;].ToString(); noGrpInsumos = new TreeNode(); noGrpInsumos.Tag = string.Empty; noGrpInsumos.BackColor = Color.AliceBlue; noGrpInsumos.ForeColor = Color.Tomato; noGrpInsumos.Text = &quot;INSUMOS&quot;; dbTview.Nodes[indexSafra].Nodes[indexFaz].Nodes[indexTalhao].Nodes[indexMovimentos].Nodes.Add(noGrpInsumos); } } if (!((string)drCusteio[&quot;DESC_PRODUTO_INS&quot;].ToString() == sgnInsumos)) { noInsumos = new TreeNode(); noInsumos.ImageIndex = 1; noInsumos.Tag = &quot;Insumos&quot;; noInsumos.Text = drCusteio[&quot;DESC_PRODUTO_INS&quot;].ToString(); dbTview.Nodes[indexSafra].Nodes[indexFaz].Nodes[indexTalhao].Nodes[indexMovimentos].Nodes.Add(noInsumos); indexInsumos = noInsumos.Index; sgnInsumos = drCusteio[&quot;DESC_PRODUTO_INS&quot;].ToString(); }</pre> Eis o meu código para habilitar pages do tabControl<br/> <pre lang="x-c#">private void dbTview_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { /* string PathNode = e.Node.FullPath; string[] WordPath = PathNode.Split(new char[] { '\\' }); int WordPathLength = WordPath.Length; this.Text = string.Join(&quot; &quot;, WordPath); if (e.Node.Tag.ToString() != string.Empty) { MessageBox.Show(e.Node.Tag.ToString()); switch (e.Node.Tag.ToString()) { case &quot;Safra&quot;: PathSafra = e.Node.Text; MostraBarraBtns(); lblTitulo.Text = &quot;Movimento de Abertura&quot;; tcCusto.SelectedIndex = 0; clsImportaMov.Safra = Safra_; break; case &quot;Fazendas&quot;: PathFaz = e.Node.Text.Split('-')[0]; //WordPath[1].Substring(0, 2); EscondeBarraBtns(); lblTitulo.Text = &quot;Movimento das Fazendas&quot;; tcCusto.SelectedIndex = 1; btnCancela.Enabled = false; btnAlterar.Enabled = true; btnSalva.Enabled = false; bdsFaz.Filter = &quot;SAFRA_FAZ=&quot; + &quot;'&quot; + PathSafra + &quot;'&quot; + &quot; and ID_FUNDO_AGRIC_FAZ=&quot; + &quot;'&quot; + PathFaz + &quot;'&quot;; Validacoes.ValidaRdButton(rbSim, rbNao); break; case &quot;Talhoes&quot;: PathTalhoes = e.Node.Text; EscondeBarraBtns(); lblTitulo.Text = &quot;Movimento dos Talhões&quot;; tcCusto.SelectedIndex = 2; btnCancelTalhao.Enabled = false; btnEditarTalhao.Enabled = true; btnSalvarTalhao.Enabled = false; bdsTalhoes.Filter = &quot;SAFRA_TALHOES=&quot; + &quot;'&quot; + PathSafra + &quot;'&quot; + &quot; and ID_FUNDO_AGRIC_TALHOES=&quot; + &quot;'&quot; + PathFaz + &quot;'&quot; + &quot; and ID_TALHAO_TALHAO=&quot; + &quot;'&quot; + PathTalhoes + &quot;'&quot;; Validacoes.ValidaRdButton(rbSimTalhao, rbNaoTalhao); break; case &quot;Movimentos&quot;: PathMovData = e.Node.Text.Split('-')[0]; PathMovAtiv = e.Node.Text.Split('-')[1]; btnNovoMov.Enabled = true; btnSalvarMov.Enabled = false; btnAlterarMov.Enabled = true; btnCancelMov.Enabled = false; btnExcluirMov.Enabled = false; EscondeBarraBtns(); lblTitulo.Text = &quot;Movimento de Mão de Obra&quot;; tcCusto.SelectedIndex = 3; bdsMov.Filter = &quot;SAFRA_CTALHAO=&quot; + &quot;'&quot; + PathSafra + &quot;'&quot; + &quot; and ID_FUNDO_AGRIC_CTALHAO=&quot; + &quot;'&quot; + PathFaz + &quot;'&quot; + &quot; and ID_TALHAO_CTALHAO=&quot; + &quot;'&quot; + PathTalhoes + &quot;'&quot; + &quot; and DATA_LANCAMENTO_CTALHAO=&quot; + &quot;'&quot; + PathMovData + &quot;'&quot; + &quot; and COD_ATIVIDADE_CTALHAO=&quot; + &quot;'&quot; + PathMovAtiv + &quot;'&quot;; break; case &quot;Insumos&quot;: PathInsumos = e.Node.Text; bdsInsumos.Filter = &quot;SAFRA_INS=&quot; + &quot;'&quot; + PathSafra + &quot;'&quot; + &quot; and ID_FUNDO_AGRIC_INS=&quot; + &quot;'&quot; + PathFaz + &quot;'&quot; + &quot; and ID_TALHAO_INS=&quot; + &quot;'&quot; + PathTalhoes + &quot;'&quot; + &quot; and DATA_LANCAMENTO_INS=&quot; + &quot;'&quot; + PathMovData + &quot;'&quot; + &quot; and COD_ATIVIDADE_INS=&quot; + &quot;'&quot; + PathMovAtiv + &quot;'&quot; + &quot; and DESC_PRODUTO_INS=&quot; + &quot;'&quot; + PathInsumos + &quot;'&quot;; EscondeBarraBtns(); lblTitulo.Text = &quot;Lançamentos de Insumos&quot;; tcCusto.SelectedIndex = 4; break; case &quot;Maquinas&quot;: PathHrMaq = e.Node.Text; bdsMaquinas.Filter = &quot;SAFRA_MAQ=&quot; + &quot;'&quot; + PathSafra + &quot;'&quot; + &quot; and ID_FUNDO_AGRIC_MAQ=&quot; + &quot;'&quot; + PathFaz + &quot;'&quot; + &quot; and ID_TALHAO_MAQ=&quot; + &quot;'&quot; + PathTalhoes + &quot;'&quot; + &quot; and DATA_LANCAMENTO_MAQ=&quot; + &quot;'&quot; + PathMovData + &quot;'&quot; + &quot; and COD_ATIVIDADE_MAQ=&quot; + &quot;'&quot; + PathMovAtiv + &quot;'&quot; + &quot; and ID_MAQUINA=&quot; + &quot;'&quot; + PathHrMaq + &quot;'&quot;; EscondeBarraBtns(); lblTitulo.Text = &quot;Serviços de Máquinas&quot;; tcCusto.SelectedIndex = 5; break; //PAREI AQUI , FSLTS CHAMAT TBCONTROL MAQUINMAS /* case &quot;Maquinas&quot;: Path = e.Node.Text; bdsMaoObra.Filter = &quot;SAFRA_INS=&quot; + &quot;'&quot; + PathSafra + &quot;'&quot; + &quot; and ID_FUNDO_AGRIC_INS=&quot; + &quot;'&quot; + PathFaz + &quot;'&quot; + &quot; and ID_TALHAO_INS=&quot; + &quot;'&quot; + PathTalhoes + &quot;'&quot; + &quot; and DATA_LANCAMENTO_INS=&quot; + &quot;'&quot; + PathMovData + &quot;'&quot; + &quot; and DESC_ATIVIDADE_INS=&quot; + &quot;'&quot; + PathMovAtiv + &quot;'&quot; + &quot; and DESC_PRODUTO_INS=&quot; + &quot;'&quot; + PathInsumos + &quot;'&quot;; EscondeBarraBtns(); lblTitulo.Text = &quot;Serviços de Máquinas&quot;; tcCusto.SelectedIndex = 6; break } }*/ }</pre><hr class="sig">JOABWed, 01 Apr 2009 23:06:40 Z2009-04-01T23:06:40Z