How do I set a TreeView Check box to partially checked? - c#

I have a asp.net treeview control that I need to be able to set a parent node to partially checked to show that child nodes are checked. Basically I need a 3 state or multi-state checkbox. All I can see from looking through the code is ways to set checked true or false.
Thanks.

There is no 3-state or multi-state checkbox in the .Net framework, mostly because this functionality isn't supported in HTML for a checkbox. There are a number of third party components which do this (such as "FolderView" controls). Or you could pretty easily roll your own server control for this. Sorry for the bad news.

I've done this before. What you essentially do is keep track of the state of the underlying checkbox. Utilizing a custom javascript class and CSS sprites for your images, you overlay the checkbox with the appropriate image.
Here is a quick example I found
http://www.codeproject.com/KB/aspnet/TriStateCheckBox.aspx
Here is the concept of CSS Sprites and the tri-state checkbox. I've done something along these lines.
http://shamsmi.blogspot.com/2008/12/tri-state-checkbox-using-javascript.html

Related

How to check some of the checkbox inside multiple checkbox list using Selenium in c#

I am working on Automation Project, there are multiple checkboxes and they don't have any ID.
CheckBox look like,
and i want to check Level 3 A and Level 1 B checkBox.
Added DOM pictures:
Thanks in Advance.
Overall idea:
For handling situations like this we need to use the advanced xpathing methods. In general we are having 13 xpath axes, which we can use to navigate in the DOM effectively keeping some element as the reference. Refer here for more details regarding the various xpath axes.
https://www.w3schools.com/xml/xpath_axes.asp
In this case, i am keeping the element with text Levle 3 A as reference and moving to its checkbox. We can update the name the checkbox alone to click that particular box.
"//span[contains(text(),'Levle 3 A')]/parent::span/input"
Hope this helps. Thanks.

Winforms UI Dynamically Displaying Parts

I came across a tutorial and some example code for an audio converter. You select the format you want to convert to from a drop down, and when you do all sorts of options appear in a previously blank area, different options based on the format you choose. It's called Audio Converter .NET and is from same author as Audio CD Ripper .NET. I can't find the tutorial, but here is a screenshot.
See how on the right there is extra controls that are not on the left. I was experimenting trying to add another category. I added it to the dropdown, but am unsure how to make it so certain fields come up when it is selected.
I understand that they create those controls for those items, but I don't see how they call the correct one when the combo box selects something. I see controls are created, but if I try to duplicate the controls into another entry in the combo box they don't show up for either the new or old one I was duplicating from.
What's the best way to go about achieving something like this?
Thanks
The easiest way is to create the controls needed for every option in the dropdown inside a panel, and simply turn it's visibility property from false to true whenever it's corresponding option is selected using the combobox's SelectedIndexChanged event handler. (And don't forget to turn the current visible panel's visibility to false)

Disable auto grouping on Windows forms

I read a question on the subject here, but the provided answer doesn't fit my case, and like said, "is a bit overkill".
I have a bunch of radio buttons in a table layout panel on a form, and .NET has decided to manage them on its own, unchecking the others when one is checked, and I don't want that.
From what I understood this is due to .NET grouping controls inside of a same container.
How do I disable that ?
Thanks.
Set the AutoCheck property to false on each RadioButton and then handle check/uncheck logic in the Click event.

How to toggle visibilty of a Wizard Page of Devexpress XtraWizard control

I have a problem: I am using devexpress wizard control and want to toggle visibility of wizardpage on the basis of a checkbox input.
Problem:
If suppose checkbox A is checked then wizard page X must be visible while going to and fro in wizard control else page should not be visible.
What I have tried:
tried to toggle visibility in SelectedPageChanging event - didn't get success
tried to add or remove page from parent control - didn't get success
Please help me out in this..
You could:
handle the SelectedPageChanging event.
Check the Page property of the event arguments is the page right before the page to show/hide.
If true, set the Cancel property to true.
Set the SelectedPage to your desired page, depending on your checkbox A's state.
You could also optionally theck the Direction property to see whether the user is navigating forward or backward.
General hint:
When dealing with DevExpress questions/issues, the DevExpress Support Center always was the most useful location to ask my questions or browse for solutions.
Even Stack Overflow cannot compete with there speed and depths of anwsers (IMHO).
So if my answer (or the other answers) do not satisfy your need, I would recommend that you go to the Support Center and ask there for advise.
I got this from devexpress below is the link for the same
How to prevent a specific page from being activated

Dynamic top down list of controls in WindowsForms and C#?

In our project, SharpWired, we're trying to create a download component similar to the download windows in Firefox or Safari. That is, one single top down list of downloads which are custom controls containing progress bars, buttons and what not.
The requirements are that there should be one single list, with one element on each row. Each element must be a custom control. The whole list should be dynamically re-sizable, so that when you make it longer / shorter the list adds a scroll bar when needed and when you make it thinner / wider the custom controls should resize to the width of the list.
We've tried using a FlowLayoutPanel but haven't gotten resizing to work the way we want to. Preferably we should only have to set anchoring of the custom controls to Left & Right. We've also thought about using a TableLayoutPanel but found adding rows dynamically to be a too big overhead so far.
This must be quite a common use case, and it seems a bit weird to me that the FlowLayoutPanel has no intuitive way of doing this. Has anyone done something similar or have tips or tricks to get us under way?
Cheers!
/Adam
If you don't want to use databinding (via the DataRepeater control, as mentioned above), you could use a regular Panel control and set its AutoScroll property to true (to enable scrollbars).
Then, you could manually add your custom controls, and set the Dock property of each one to Top.
.NET 3.5 SP1 introduced a DataRepeater Windows Forms control which sounds like it'd do what you want. Bind it to the list of "downloads" (or whatever your list represents) and customize each item panel to include the controls you need.

Categories

Resources