SelectedNode is not working after refresh always showing null
Here i am trying to show the last selected node after reload of treeview but the selected node is always null. I am able to find the tree node from the treeview node collection but not able to assign it to tree view. Please suggeest:
public void LoadTreeViewData()
treeView.Nodes.Clear();// Clear any existing items
treeView.BeginUpdate(); // prevent overhead and flicker
LoadBaseNodes();//Populate all nodes
treeView.EndUpdate();
treeView.Refresh();
treeView.ExpandAll();
if (!string.IsNullOrEmpty(m_oSelectedNode_NAME))
TreeNode treeNodes = treeView.FlattenTree()
.Cast<TreeNode>()
.Where(r => Convert.ToDecimal(r.Tag) == Convert.ToDecimal(m_oSelectedNode_NAME))
.ToArray();
treeView.SelectedNode = treeNodes[0];
treeView.Focus();
c# winforms treeview
|
show 10 more comments
Here i am trying to show the last selected node after reload of treeview but the selected node is always null. I am able to find the tree node from the treeview node collection but not able to assign it to tree view. Please suggeest:
public void LoadTreeViewData()
treeView.Nodes.Clear();// Clear any existing items
treeView.BeginUpdate(); // prevent overhead and flicker
LoadBaseNodes();//Populate all nodes
treeView.EndUpdate();
treeView.Refresh();
treeView.ExpandAll();
if (!string.IsNullOrEmpty(m_oSelectedNode_NAME))
TreeNode treeNodes = treeView.FlattenTree()
.Cast<TreeNode>()
.Where(r => Convert.ToDecimal(r.Tag) == Convert.ToDecimal(m_oSelectedNode_NAME))
.ToArray();
treeView.SelectedNode = treeNodes[0];
treeView.Focus();
c# winforms treeview
It would be awesome if you could provide a Minimal, Complete, and Verifiable example.
– mjwills
Nov 14 '18 at 20:32
WinForms? ASP? I can figure out what FlattenTree is doing, but it's not a standard function in the WinForm's TreeView control. Wouldn't it just betreeView.SelectedNode = tns[0];
Not sure why you are doing all that other stuff.
– LarsTech
Nov 14 '18 at 20:34
Here flatten tree is nothing but returning IEnumerable<TreeNode> collection to find me last save node.Its a winform control.
– Delta
Nov 14 '18 at 21:03
Here problem is although i found the tree node but when i assign to selectedNode . SelectedNode stays null.
– Delta
Nov 14 '18 at 21:07
Yes . It is decimal and its returning me the tree node but while assigning the selected node is null.
– Delta
Nov 14 '18 at 21:11
|
show 10 more comments
Here i am trying to show the last selected node after reload of treeview but the selected node is always null. I am able to find the tree node from the treeview node collection but not able to assign it to tree view. Please suggeest:
public void LoadTreeViewData()
treeView.Nodes.Clear();// Clear any existing items
treeView.BeginUpdate(); // prevent overhead and flicker
LoadBaseNodes();//Populate all nodes
treeView.EndUpdate();
treeView.Refresh();
treeView.ExpandAll();
if (!string.IsNullOrEmpty(m_oSelectedNode_NAME))
TreeNode treeNodes = treeView.FlattenTree()
.Cast<TreeNode>()
.Where(r => Convert.ToDecimal(r.Tag) == Convert.ToDecimal(m_oSelectedNode_NAME))
.ToArray();
treeView.SelectedNode = treeNodes[0];
treeView.Focus();
c# winforms treeview
Here i am trying to show the last selected node after reload of treeview but the selected node is always null. I am able to find the tree node from the treeview node collection but not able to assign it to tree view. Please suggeest:
public void LoadTreeViewData()
treeView.Nodes.Clear();// Clear any existing items
treeView.BeginUpdate(); // prevent overhead and flicker
LoadBaseNodes();//Populate all nodes
treeView.EndUpdate();
treeView.Refresh();
treeView.ExpandAll();
if (!string.IsNullOrEmpty(m_oSelectedNode_NAME))
TreeNode treeNodes = treeView.FlattenTree()
.Cast<TreeNode>()
.Where(r => Convert.ToDecimal(r.Tag) == Convert.ToDecimal(m_oSelectedNode_NAME))
.ToArray();
treeView.SelectedNode = treeNodes[0];
treeView.Focus();
c# winforms treeview
c# winforms treeview
edited Nov 14 '18 at 21:05
Delta
asked Nov 14 '18 at 20:17
DeltaDelta
1146
1146
It would be awesome if you could provide a Minimal, Complete, and Verifiable example.
– mjwills
Nov 14 '18 at 20:32
WinForms? ASP? I can figure out what FlattenTree is doing, but it's not a standard function in the WinForm's TreeView control. Wouldn't it just betreeView.SelectedNode = tns[0];
Not sure why you are doing all that other stuff.
– LarsTech
Nov 14 '18 at 20:34
Here flatten tree is nothing but returning IEnumerable<TreeNode> collection to find me last save node.Its a winform control.
– Delta
Nov 14 '18 at 21:03
Here problem is although i found the tree node but when i assign to selectedNode . SelectedNode stays null.
– Delta
Nov 14 '18 at 21:07
Yes . It is decimal and its returning me the tree node but while assigning the selected node is null.
– Delta
Nov 14 '18 at 21:11
|
show 10 more comments
It would be awesome if you could provide a Minimal, Complete, and Verifiable example.
– mjwills
Nov 14 '18 at 20:32
WinForms? ASP? I can figure out what FlattenTree is doing, but it's not a standard function in the WinForm's TreeView control. Wouldn't it just betreeView.SelectedNode = tns[0];
Not sure why you are doing all that other stuff.
– LarsTech
Nov 14 '18 at 20:34
Here flatten tree is nothing but returning IEnumerable<TreeNode> collection to find me last save node.Its a winform control.
– Delta
Nov 14 '18 at 21:03
Here problem is although i found the tree node but when i assign to selectedNode . SelectedNode stays null.
– Delta
Nov 14 '18 at 21:07
Yes . It is decimal and its returning me the tree node but while assigning the selected node is null.
– Delta
Nov 14 '18 at 21:11
It would be awesome if you could provide a Minimal, Complete, and Verifiable example.
– mjwills
Nov 14 '18 at 20:32
It would be awesome if you could provide a Minimal, Complete, and Verifiable example.
– mjwills
Nov 14 '18 at 20:32
WinForms? ASP? I can figure out what FlattenTree is doing, but it's not a standard function in the WinForm's TreeView control. Wouldn't it just be
treeView.SelectedNode = tns[0];
Not sure why you are doing all that other stuff.– LarsTech
Nov 14 '18 at 20:34
WinForms? ASP? I can figure out what FlattenTree is doing, but it's not a standard function in the WinForm's TreeView control. Wouldn't it just be
treeView.SelectedNode = tns[0];
Not sure why you are doing all that other stuff.– LarsTech
Nov 14 '18 at 20:34
Here flatten tree is nothing but returning IEnumerable<TreeNode> collection to find me last save node.Its a winform control.
– Delta
Nov 14 '18 at 21:03
Here flatten tree is nothing but returning IEnumerable<TreeNode> collection to find me last save node.Its a winform control.
– Delta
Nov 14 '18 at 21:03
Here problem is although i found the tree node but when i assign to selectedNode . SelectedNode stays null.
– Delta
Nov 14 '18 at 21:07
Here problem is although i found the tree node but when i assign to selectedNode . SelectedNode stays null.
– Delta
Nov 14 '18 at 21:07
Yes . It is decimal and its returning me the tree node but while assigning the selected node is null.
– Delta
Nov 14 '18 at 21:11
Yes . It is decimal and its returning me the tree node but while assigning the selected node is null.
– Delta
Nov 14 '18 at 21:11
|
show 10 more comments
1 Answer
1
active
oldest
votes
This problem is happening because i am trying to Update the selected node inside the Tree view after label edit event. I put a timer inside After label edit to resolve the issue and set the Selected node it works for me.
var tnm = new Timer() Enabled = true, Interval = 30 ;
tnm.Tick += delegate
SetSelectioNode();
tnm.Dispose();
;
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53308119%2fselectednode-is-not-working-after-refresh-always-showing-null%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This problem is happening because i am trying to Update the selected node inside the Tree view after label edit event. I put a timer inside After label edit to resolve the issue and set the Selected node it works for me.
var tnm = new Timer() Enabled = true, Interval = 30 ;
tnm.Tick += delegate
SetSelectioNode();
tnm.Dispose();
;
add a comment |
This problem is happening because i am trying to Update the selected node inside the Tree view after label edit event. I put a timer inside After label edit to resolve the issue and set the Selected node it works for me.
var tnm = new Timer() Enabled = true, Interval = 30 ;
tnm.Tick += delegate
SetSelectioNode();
tnm.Dispose();
;
add a comment |
This problem is happening because i am trying to Update the selected node inside the Tree view after label edit event. I put a timer inside After label edit to resolve the issue and set the Selected node it works for me.
var tnm = new Timer() Enabled = true, Interval = 30 ;
tnm.Tick += delegate
SetSelectioNode();
tnm.Dispose();
;
This problem is happening because i am trying to Update the selected node inside the Tree view after label edit event. I put a timer inside After label edit to resolve the issue and set the Selected node it works for me.
var tnm = new Timer() Enabled = true, Interval = 30 ;
tnm.Tick += delegate
SetSelectioNode();
tnm.Dispose();
;
answered Nov 16 '18 at 14:41
DeltaDelta
1146
1146
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53308119%2fselectednode-is-not-working-after-refresh-always-showing-null%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It would be awesome if you could provide a Minimal, Complete, and Verifiable example.
– mjwills
Nov 14 '18 at 20:32
WinForms? ASP? I can figure out what FlattenTree is doing, but it's not a standard function in the WinForm's TreeView control. Wouldn't it just be
treeView.SelectedNode = tns[0];
Not sure why you are doing all that other stuff.– LarsTech
Nov 14 '18 at 20:34
Here flatten tree is nothing but returning IEnumerable<TreeNode> collection to find me last save node.Its a winform control.
– Delta
Nov 14 '18 at 21:03
Here problem is although i found the tree node but when i assign to selectedNode . SelectedNode stays null.
– Delta
Nov 14 '18 at 21:07
Yes . It is decimal and its returning me the tree node but while assigning the selected node is null.
– Delta
Nov 14 '18 at 21:11