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 1 year ago.
Improve this question
I have a ListView and it adds an item per second dynamically in C# WPF. Since I feel it will get stuck after thousands of items I clear it when it holds more than 100 items.
But then it doesn't look good and disappears all of a sudden. Is there a way by code to make it look like items continuously flowing? How can I delete a particular item when it reaches to 100 items so the items would look like flowing?
Before adding new items check how many are already there and remove some (the oldest ones in the beginning) to stay under limit:
int limit = 100;
while(myListView.Items.Count >= limit)
{
myListView.Items.RemoveAt(0);
}
myListView.Items.Add("new item");
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 is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I have been trying for few hours to add a DataGridViewCheckBoxColumn to an existing DataGridView with the designer and through code. The CheckBoxCell is not displaying the square (or state) on the UI. However, when I tried some code that I found (and forgot to change the index), I got it working and displaying normally.
So I am wondering why you cannot use a DataGridViewCheckBoxColumn at the last index of the DataGridView.Columns ?
To be more explicit:
Why does this work
MyDataGridView.Columns.Insert(0, myCheckBoxColumn);
When this does not work
MyDataGridView.Columns.Insert(7, myCheckBoxColumn);
Note: The myCheckBoxColumn variable did not change between the two lines. It is exactly the same and is irrelevant to the actual problem.
Edit:
Using the Add method like bellow does not solve the problem.
MyDataGridView.Columns.Add(myCheckBoxColumn);
Resolved:
My problem was related to the handling of the CellPainting event of the DataGridView. At the end of the function, the property Handled of the DataGridViewCellPaintingEventArgs was set to true. This was causing the DataGridViewCheckBoxColumn to not display properly.
If you want to add a column to the right, use the Add method of DataGridViewColumnCollection instead:
MyDataGridView.Columns.Add(myCheckBoxColumn);
https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcolumncollection.add(v=vs.110).aspx
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}