Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
In my application I am trying to hide the values in my drop down list while it carries out the required functionality. As shown below you can see the drop down showing a value. The values are being pulled from a database.
When selected it would show the values below:
I would prefer if the values are not shown. Meaning I would want the dropdown values to not be shown but still carry out the fill operation as shown above.
So to explain more clearly, My comboBox which contains the value "123456789" would pass the values "P10434" and "Jev Pharma" to the respective textBoxes below respectively.Instead of showing my dropdown values while typing(auto suggest currently does this) I would instead want the dropdown list to not suggest any values at all. Meaning once I type "1234567..." it would not show any values int he comboBox but rather accept the info being typed in and pass the corresponding values from the database to the texboxes below.
I have tried changing the properties of the comboBox by removing append and suggest but the functionality is different. It no longer fills the data but instead just allows typing of a value. I am not sure how to approach this. Any suggestions?
Set the properties as follows:
comboBox1.AutoCompleteMode = AutoCompleteMode.Append;
comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;
comboBox1.DropDownStyle = ComboBoxStyle.DropDown;
This will append the suggestions when typing without showing the list.
You can handle the appropriate event per your requirement to fill your textboxes.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I have aspx page.having an issue is that if we select first time option from drop down value gets appears on the page.but when we select second time option from drop down still previous data getting appears. how do i clear all the previous data after drop-down SelectedIndexChanged Event..?
As you have not provided the code when i'm writing this answer. In Asp.net u can achieve this by using jquery. I'm using club dropdown list with ID clubs as an example. This event will bind to the list and will keep on updating selected variable when the selectedIndex change. Then you can simply pass the selected variable value to lets say a span element with id spanClub
$(document).ready(() => {
$('#Clubs').change(() => {
let selected = $('#Clubs :selected').text();
$('#spanClub').text(selected);
});
});
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I need to bind a list an observablecollection to the listview. This listview must be updated each time when data changes in the observablecollection.
For now I can only bind one element of the observablecollection to the listview at the same time, whenever the second one is bound, it will cover the last one.
My purpose is to bind all the data which are created by calling LoadAlarms() in to the listview .
These are my XAML codes:
my Alarms class
My codes in viewmodel
the fist time LoadAlarms are called, I have the result
The second time LoadAlarms are called,I have the result
I would like to display these both results to the listview but I can only see the last update.
Your class Alarms must be inherited from NotificationObject and its properties must do RaisePropertyChanged whenever they change.
ObservableCollection should be allocated once and then only use add, remove etc.
Why do you have a ListView that contains a grid that contains a grid that contains another ListView? What are you trying to do if I may ask.
Hope this helps..
Each time you call LoadAlarm() you overwrite your observable collection with a new one.
Call AlarmList = new ObservableCollection<Alarms>() only once for example in a constructor.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am making an application where the user has to choose a value from a combobox. Based on the users choice the form should be filled with relevant labels and textboxes. How do I achieve this?
One way I think this could be achieved is by creating all labels and textboxes, and based on the users choice hide the irrelevant ones. But this seems to be very cumbersome. Is there any neat way to do it?
Could you just give me leads from where I could pick up the many
ways? #Jumpei – user2276910 8 mins ago
Just you know, everything in the comments was a lead of some kind. Whichever approach you chose, showing/hiding data is essential. Your combobox selection is a private case. Much more frequently, you gonna need/use this to handle user access so there is no way you gonna start building your application and at some point discover that you can't show/hide data or controls. That's just not the case. In fact since each approach will give you that option, to get a concrete answer will require a lot more information about the project itself and the overall architecture than just this one particular form.
Having said that I will suggest you approach which I think is not the best one, but very intuitive and at some point when you feel more confident you change this.
So in order to achieve this create the form setting the default visibility to all elements. Adding/removing controls dynamically is not that trivial but setting the visibility option is pretty straight forward so I think it's better to start by using the visibility option.
When you are ready with the default state of the form you gonna need few methods. First, an event handler for the combobox select which should be something like this:
private void ComboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
ComboBox comboBox = (ComboBox) sender;
string userSelection = (string)ComboBox1.SelectedItem;
From now on you should make a few things. First check if the userSelection is something valid. This check is essential, after you are sure that this is valid selection you gonna proceed (and we are still in the SelectedIndexChanged event) by calling a a method :
private void SetControlsToDefault()
{
}
This method will contains all your controls with their default visibility status. That's required because when the user make more than one selection with the combobox if we don't hide the once that were shown on the previous selection you will end up with visible controls when they should be hidden for the certain selection.
So once we are sure that the form is returned to it's initial state we need to check what exactly has the user selected and show the relevant controls.
Here some would suggest to use switch I'll suggest if-else if statements since I think this will make it more understandable but you can change it if you like so again in the event handler after calling SetControlsToDefault(); we have this:
if (userSelection.Equals("selection1"))
{
ShowControlsForSelectionOne();
}
else if (userSelection.Equals("selection2"))
{
ShowControlsForSelectionTwo();
}
else if (userSelection.Equals("selection3"))
{
ShowControlsForSelectionThree();
}
where ShowControlsForSelectionOne(), ShowControlsForSelectionTwo(), ShowControlsForSelectionThree() are all private methods where you gonna set the visibility only to those elements relevant to the selection. And that should be all. This is one of the many ways to complete this task.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have a requirement to show a list of details in a ToolTip. Is this possible to do? I tried setting a Dictionary to a Tooltip in the code behind. It just displayed Collection.?? Kindly help
You can display anything you choose in a tooltip (WPF is nice like that - you can template anything). However, when you set a Dictionary to the tooltip value, it doesn't know what you want to do with it and defaults to a useless string of text.
Try setting a template for your tooltip that would render the dictionary in a useful way. Since ToolTip is a ContentControl, it will work this out for itself if there's a suitable template available (either keyed by type, or set within the ToolTip).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am Creating an app with C#. I have a ListView on the Main Form(FormM) which lists all the record, i can select on record and edit it in the new form(FormC). Now I want to have a Navigator on the Main Form. Suppose that the FormC is open and showing a record for edit. in That case i want that if i click the navigate button on the Main Form, the value on the FormC changes according the next or previous move of navigation.
the Navigation buttons is in the FormC in any samples that i found in internet. but i want those be separated.
any sample or idea is appreciated.
In your FormM, make the listview a static member, to do this, go to FormM.Designer.cs, locate the declaration of listview and change it to public static type from private type. After you do this, plenty of errors will be reported in the same file. To fix those, replace all this.listview with only listview.
The above configuration will make your listview accessible from any other form. To access the listview from FormC, user FormM.listview.
Similarly change the Text box/area from FormC to public static. This will make the textbox accessible from FormM.
When you press next and previous buttons, change the selection controls between items and in the SelectedItemChanged action function, put the code to send the selected item to FormC's text box.
Eg: FormC.textbox1.text = {your code to fetch the selected item}