.net

How to format all textbox values on LostFocus event in Winform

旧城冷巷雨未停 提交于 2021-02-05 08:42:18
问题 I need to add commas to thousand position of every numerical value in any related text-box value upon lost-focus event. I have created the following function: public static void FormatNumerical(this Control control) { if (!(control is TextBox) || !control.Text.IsNumeric()) return; control.Text = String.Format("{0:n}", control.Text); } Is there a way to apply this method to all lost focus events for all my textboxes in my winform application in one shot? 回答1: Is that you need? ProcessTextBoxes

XamarinForms DataGridView (DevExpress) doesn't show values on some fields

坚强是说给别人听的谎言 提交于 2021-02-05 08:33:25
问题 So I am consuming a Web Service and I have the value: CustomersList with the list of customers. When I bind the Data to my Grid like this: <ContentPage.BindingContext> <vm:ApiVewModel/> </ContentPage.BindingContext> <dxg:DataGridView x:Name="grid" ItemsSource="{Binding CustomersList}"> </dxg:DataGridView> I can see the Grid but I see only certain fields like OID and CategoryFPA. The other columns are shown but they are empty. While in the Json (response) they have a value. Any idea of what is

DateTime precision in .NET core

£可爱£侵袭症+ 提交于 2021-02-05 08:20:10
问题 Following Eric Lippert's post years back on precision of DateTime , I ran his test on .netcore and .NET Framework 4.5.2, on the same machine with Windows 10. var n = 1000; int i = 0; long[] diffs = new long[n]; while (i++ < n-1) { if (ticks != DateTime.Now.Ticks) { var newTicks = DateTime.UtcNow.Ticks; var diff = newTicks - ticks; diffs[i] = diff; ticks = newTicks; } } foreach (var d in diffs) { if (d == 0) Console.WriteLine("same"); else Console.WriteLine(d); } The result on .NET framework 4

DateTime precision in .NET core

丶灬走出姿态 提交于 2021-02-05 08:20:01
问题 Following Eric Lippert's post years back on precision of DateTime , I ran his test on .netcore and .NET Framework 4.5.2, on the same machine with Windows 10. var n = 1000; int i = 0; long[] diffs = new long[n]; while (i++ < n-1) { if (ticks != DateTime.Now.Ticks) { var newTicks = DateTime.UtcNow.Ticks; var diff = newTicks - ticks; diffs[i] = diff; ticks = newTicks; } } foreach (var d in diffs) { if (d == 0) Console.WriteLine("same"); else Console.WriteLine(d); } The result on .NET framework 4

dll used by CLR at runtime

隐身守侯 提交于 2021-02-05 08:19:10
问题 I've got a C# application which refers to a .NET DLL. If this DLL is present both in my application's bin directory and GAC, then which one will be picked up by the CLR at runtime? If GAC has the latest version, would that version be used instead of the one present in bin ? And how do I force the CLR to always use the one in my bin instead of GAC? According to MSDN: The CLR checks the global assembly cache, codebases specified in configuration files, and then checks the application's

Deserialize tag with body and attributes to an object

五迷三道 提交于 2021-02-05 08:17:25
问题 How can I deserialize XML like that to an object: <Root> <Element Attr="AttrValue1">BodyValue1</Element> <Element Attr="AttrValue2">BodyValue2</Element> <Element Attr="AttrValue3">BodyValue3</Element> </Root> I need the exact objects structure with appropriate attributes. I've tried: [XmlRoot("Root")] public class EventFieldsRoot { [XmlElement("Element")] public List<Element> Elements{ get; set; } } public class Element { [XmlAttribute] public string Attr { get; set; } [XmlElement("")] public

how to split ObservableCollection

放肆的年华 提交于 2021-02-05 08:15:59
问题 i have ObservableCollection with 100 records. now i want to get split that collection in 10 new collection each having 10 records. it means 1 collection = 100 records (10 collection = 10 records) = 1 collection any help will be apricited. 回答1: Using Linq var collection=new ObservableCollection<int>(Enumerable.Range(1,100)); collection.Aggregate(new ObservableCollection<ObservableCollection<int>>(), (x,i)=>{ if (!x.Any() || x.Last().Count()==10) x.Add(new ObservableCollection<int>()); x.Last()

Gmail API - The format of value '= Get Labels google-api-dotnet-client/1.25.0.0 (gzip)' is invalid

老子叫甜甜 提交于 2021-02-05 08:13:52
问题 I started exploring Gmail API. I followed the tutorial to show labels list (https://developers.google.com/gmail/api/quickstart/dotnet), and worked fine. HELP is highly appreciated When I modified the flow of program, here it gives me the error. I cannot trace the error. It gives me error on Execute() method. Error: The format of value '= Get Labels google-api-dotnet-client/1.25.0.0 (gzip)' is invalid here is my code. public static class Labels { public static void ListLabels ( ) { try { var

How do I connect to a hidden SSID in Windows 10 programmatically?

喜你入骨 提交于 2021-02-05 08:13:28
问题 I have spent ages on this and I am stuck. I am trying to connect to a known hidden SSID programmatically. I am using the following code await firstAdapter.ScanAsync(); WiFiAvailableNetwork network = firstAdapter.NetworkReport.AvailableNetworks.FirstOrDefault(n => n.Ssid == ssid); The problem is I need to supply as a first an object of type WiFiAvailableNetwork but AvailableNetworks only brings back non-hidden SSIDs. public IAsyncOperation<WiFiConnectionResult> ConnectAsync

Python objects compared to .NET objects

故事扮演 提交于 2021-02-05 08:12:13
问题 I'm very comfortable with .NET objects and its framework for reference vs value types. How do python objects compare to .NET objects? Specifically, I'm wondering about equality obj1 == obj2 , hash-ability (i.e. being able to put in a dict), and copying. For instance, by default in .NET, all objects are reference types and their equality and hash code is determined by their address in memory. Additionally, assigning a variable to an existing object just makes it point to that address in memory