Hi,
There is a requirement to remove any values present in the Ultranumericeditor at runtime when a button is clicked. I have been trying this for sometime and could not see any property of the Ultranumericeditor supports this. Kindly advise.
Hello Preeth,
To clear the values in UltraNumericEditor at runtime upon a button click, you can write something like below in the click event.private void button1_Click(object sender, EventArgs e) { this.ultraNumericEditor1.Value = null; }
Make sure you set the below property in order to allow null values in UltraNumericEditor. this.ultraNumericEditor1.Nullable = true;Please let me know if I may be of further assistance.
Sincerely,Sahaja KokkalagaddaAssociate Software Developer
Yes the nullable property is true for my ultranumericeditor.
To be more clear on this.. My screen opens and i set a value to the ultranumericeditor, say 25 via its binding source using a strongly typed in-memory cache of data. So this 25 will be present in the ultranumericeditor. Now on a specific scenario, a button pops up in that screen and when i click on it i need to clear the value present in there, i.e., 25 should be removed and the editor should be blank. Note: we can manually remove this by selecting the data present in the editor and delete them using delete button. I want to achieve this through code and value property does not help me on this. Kindly advise.
Hello,
Yes, the DataSource will accept null. We need to find the a way out as quickly as possible. I will try to build a sample, but not sure whether i can do this anytime soon. Any other possibilities?..
Yes, the DataSource will accept null. We need to find a way out as quickly as possible. I will try to build a sample, but not sure whether i can do this anytime soon. Any other possibilities?..
You can refer to the attached sample on how to clear the UltraNumericEditor upon button click. I believe the reason why you were not able to clear the NumericEditor isbecause of the way its databindings are implemented. I recommend verifying the values in DataSource and the UltraNumericEditor to make sure they are in sync. One more thing that you can try is setting the value to DBNull.Value and see if that works.
Please let me know if I may be of further assistance.
Sorry to get back at this late,
I have tried your option of using DBNull.Value and it did not help me. And I was not able to run the sample code you have sent me with the software I have here, thanks anyways. But I get the idea of what you are trying to do here, making it nullable when the form loads and setting the value property to null. I have tried this already and almost everything that you could think of. What's that I can see is, we can select the value present in the UltraNumericEditor using mouse and delete it using the keyborad, but why are we not able to do so via code? could you think in this direction to see if there's something that could help?
Regards
Preeth
Hi Preeth,
I cannot see how that you would be unable to set the value by doing what you are describing via code. My belief it is in how you are databinding, or what you are databound to. If you start off with a simple sample, similar to what was sent. Just an UltraNumericEditor and a button on a form. In that scenario can you set the UltraNumericEditor to blank. Then take it a step further, databind it to a simple datatable column value. Can you still blank out the Editor. My guess is you should be able to, so the issue is in something else that is going on, likely you are triggering a rebind or your changes were rejected for some reason. Resetting the value.
Below is a quick code snippet to build the data and databind it:
private void Form1_Load(object sender, EventArgs e) { data = BuildData(10);
this.ultraNumericEditor1.Nullable = true; this.ultraNumericEditor1.DataBindings.Add("Value", data.DefaultView, "int1"); } private DataTable BuildData(int rowCount) { Random rand = new Random(1); DataTable dt = new DataTable(); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("int1", typeof(int)); for (int x = 0; x < rowCount; x++) dt.Rows.Add(string.Format("Item # {0}",x+1), rand.Next(100)); dt.AcceptChanges();
return dt; } private void ultraButton1_Click(object sender, EventArgs e) { this.ultraNumericEditor1.Value = DBNull.Value; }
Let me know if that helps,