|
Hi everyone,
I am having a tricky problem, I want some slightly unusual behaviour from a checkbox and can't seem to figure it out. Any suggestions would be most welcome. The behaviour I want is:
1. The CheckBox is enabled and ready for the user to click, IsChecked represents a bound boolean value stored in a data structure
2. The user clicks the CheckBox causing the click event to fire but the bound value in the data structure is NOT updated and the visual representation of the CheckBox is NOT updated but it is disabled to stop further clicking
3. The click event triggers a message to be sent to a remote device which takes some time to respond
4. The remote device responds causing the data structure to be updated with the new value, the binding then updates the isChecked status and the CheckBox gets reenabled for further clicking
The problem I have is that although a OneWay data binding works at not updating the data structure when the CheckBox is clicked, the visual representation does change (which I think is odd, shouldn't IsChecked now act like a pointer to the value in the data structure).
I can reverse the change in the Click() event and do the disable there as well but this is pretty messy. I can also have the set property of the data structure value to set an isEnabled value which is also bound to reenable the CheckBox but that seems messy too.
Is there a clean way to do this? Perhaps with a derived CheckBox class? How can I stop the visual representation getting updated?
Thanks
Ed
|
|
|
|
|
|
benjamin yap wrote: i wan to create on a c# application. not a .net application
AFAIK C# does not exists without .Net. Hence, not possible.
जय हिंद
|
|
|
|
|
i mean
not .aspx application... but a .exe app
|
|
|
|
|
Start by looking in to the MonthCalendar control. Customize to create a planner.
As far as searching goes, first page of Google search results will give you what you need (Although the control is not free). There is also an article here at CP(I just saw one, might be many more). Go through it.
जय हिंद
|
|
|
|
|
benjamin yap wrote: issit possible?
Yes.
benjamin yap wrote: can give me some hints on how should i start
Requirements
|
|
|
|
|
Hello,
Do someone can provide me with a simple full text search that search for english and arabic words.
I tried Lucene.dll but it not supporting arabic words.
best regards.
Elie
dghdfghdfghdfghdgh
|
|
|
|
|
Try to compose your own code, we'll be happy to help you with any bugs.
or, try rentacoder[^] if you're willing to pay to get it done, no one does work for free.
|
|
|
|
|
I'm implementing a filter, and need to indicate if the filters applied are hiding one or more row, or if all the rows are visible.
My first thought was to use DataGridView.DisplayedRowCount() , but it returns the number of rows that are actually shown on the screen. If there are enough rows to trigger a vertical scroll this isn't the same because rows that are off the top/bottom of the list are not counted.
Is there another method/property I'm not seeing, or will I have to iterate over the entire Rows collection?
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
I can think of two ways: put the filtered rows in a datatable and then get the count or iterate.
By the way, how are you doing the filtering? It might help finding a better way.
जय हिंद
|
|
|
|
|
foreach (DataGridView row in myDataGridView)
{
Row.Visible = PassesFilter (row);
}
The data is not coming from a database, and isn't coming via a datatable as a result.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
Why not have a variable to hold the number of visible and hidden rows here itself? Something like:
int VisibleRows = myDataGridView.Rows.Count;
foreach (DataGridView row in myDataGridView)
{
if(!PassesFilter (row)){
Row.Visible = false;
VisibleRows--;
}
}
जय हिंद
|
|
|
|
|
That sounds like the way to go. Sometimes the problem with refactoring older uglier code* is that obvious solutions are missed.
* I started out with two ListViews, one displayed and a hidden one storing an unfiltered copy of the data. The code cleared the displayed one and then repopulated it with rows that passed the filter.
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
Hi, I'm doing a calendar like program and I'm using buttons as time slots. And I need to simply call a method that will be called by any button that is clicked inside this time slot and when the method is called it will read the button's name.
example
btn800Am_clicked - will open timeslot
btn900Am_clicked - will open timeslot
btn1000Am_clicked - will open timeslot
private void timeslot_Click(object sender, EventArgs e)
{
calculate(x.name);
}
private void calculate(string name)
{
messagebox.show(name);
}
|
|
|
|
|
the sender is the buttun that sent the object so you can do
button x = (button)sender;
PS please put code in code blocks makes it easier to read!
|
|
|
|
|
"PS please put code in code blocks makes it easier to read!" Thanks for the suggestion will use it next time. And thank you for the quick response.
|
|
|
|
|
You already have this information - in the sender parameter. All you need do is cast it to a Button and then use the name from that, e.g.
string name = ((Button)sender).Name;
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Oww yeah... I'm quite fresh in coding. But thank you very much for the quick response and right what I needed
|
|
|
|
|
Hi,
on top of that all, you don't have to use the Name property (if the Form got designed with Visual Designer it won't like you change a Control's Name). You could use its Text property instead, or store something in the Tag property.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Yeah, I prefer to use the Tag too, that way I can associate an object with the control, much cleaner.
|
|
|
|
|
private void btn0_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
check();
if (btn.Name == btn0.Name)
{
txtcalculate.Text = txtcalculate.Text + "0";
}
if (btn.Name == btn1.Name)
{
txtcalculate.Text = txtcalculate.Text + "1";
}
if (btn.Name == btn2.Name)
{
txtcalculate.Text = txtcalculate.Text + "2";
}
}
//make all the button event to be btn0_Click
Padmanabhan
|
|
|
|
|
Thank you. Got it working now
|
|
|
|
|
hi peoples..
i m designing an application in wpf scree, of which i have to dunamically move the label.. for that i have to set the margin,
how to set the margin in c# coding??
|
|
|
|
|
yourLabelName.Margin = new Thickness(5);
Try asking in the WPF forum next time.
(Also setting the margin from code kinda breaks the idea of WPF code/UI separation, you should be binding to something instead, but I'm not gonna interfere, maybe your doing it for a good reason. Just read about MVVM and WPF design)
Simon
|
|
|
|
|
Hi there,
I'm working on a program which has to record as many video streams as it can, coming from a server. I tested the source capacity with some other programs and it got up to 100 streams coming without any problem.
So I made my own program, using a class which starts a thread. This thread opens a connection using HttpWebRequest and gets its response stream and writes incoming data into a file, all of them done synchronously.
I create one class per one video stream. using this method everything is OK just before I reach 10 records, from this time on, no new stream opens.
What do I have to do?
I'm not reaching any memory, network bandwidth or things like that.
Thanks for your help.
|
|
|
|