Jump to content

C# - Tree Kullanımı ?


pairs
 Share

Recommended Posts

  • Editor
S.a arkadaşlar C# da treedeki seçili olan checkbox ları kontrol ettirmek istiyorum ama beceremedim anlayan arkadaşlar yardımcı olabilirlermi.
Link to comment
Share on other sites

[font="Verdana"]"Checked" özelliğinin True mu False mu olduğunu kontrol etmeniz gerekiyor[/font]


if (checkBox1.Checked == true)


MessageBox.Show("Seçili");

else


            MessageBox.Show("Seçili değil");

Link to comment
Share on other sites

Bu kodu codebehinde yapistir.
treeView1 isminde ekle formuna. Checkboxlari enable yap. daha sonra aftercheck eventini treevView1_AfterCheck olarak sec.Daha sonra breakpointler koyarak debug et. Program acilinca bir tanesini check et ve debug yontemiyle izle sonuclari.


[codebox]
bool busy = false;
private void treeView1_AfterCheck(object sender, TreeViewEventArgs e)
{
if (busy) return;
busy = true;
try
{
checkNodes(e.Node, e.Node.Checked);
}
finally
{
busy = false;
}
}

private void checkNodes(TreeNode node, bool check)
{
foreach (TreeNode child in node.Nodes)
{
child.Checked = check;
checkNodes(child, check);
}
}
[/codebox]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...