.NET Programming

134K

Solutions

39K

Contributors

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

Share tech news, updates, or what's on your mind.

Sign up to Post

Trouble adding comma to bar graph data using Windows Chart Class

I am using the library:
System.Windows.Forms.DataVisualization.Charting

and found I could format (with comma) for values > 1,000

with this line of code:
ca.AxisY.LabelStyle.Format = ("##,#");

But, I can't figure out how to get the data to display also with the comma.

Best I get is the following:
Missing Comma on Data
Here is the Microsoft reference document:
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.datavisualization.charting.chart?view=netframework-4.0
0
Hi
I'm attempting to update my local movie database from information from the movie database API (TMDB API)
This picture shows my Entity Framework diagram
MovieModel3.JPGthere are several issues I need to address

People with no tmdb_id or profile path ( Every person on TMDB should have an id but not all have a picture)

movielinkperson.job as few entries, for cast this is the  cast.Character and for crew it's job eg Director

Wrong person linked to a movie

TMDB Person in the database but not linked to a movie or not in the database

Searching TMDB by persons name is ambiguous for instance search for "John Wayne" returns 13 people  

I there for need to search for people linked to movies in the database and update accordingly

In the code below I'm struggling with the logic and with this line

// this is supposed to create a movielinkpersons object but isn't happy with code after &&
  var MLP = context.movielinkpersons.Where(m => m.movieId = Movie.id && x => x.personId == PersonExists.id);

        private void UpdateBtn_Click(object sender, EventArgs e)
        {
            TMDbClient client = new TMDbClient("2c8a02fa36fb5299dcd97bbc84609899");
            using (var context = new MoviesEntities())
            {
                var allMovies = context.movies.OrderBy(m => m.title).ToArray();
                // make a list so not processing a person twice
                

Open in new window

0
Hi,

I am trying to create a CLR function to allow users to grab data from a table that changes names each month (name changes are outside my control).

I have everything compiling and running without any errors but I never get any rows back.

I have simplified things as much as possible to try to find the problem and am inserting a DataRow into the DataTable I want to return to rule out problems with the select but still don't get any rows.

C# code
using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.IO;
using Microsoft.SqlServer.Server;


public class TableFunctions
{

    [SqlFunction(FillRowMethodName = "FillCLRTest")]
    public static IEnumerable CLRTest()
    {
        string query = "SELECT [id]" +
                "FROM table";

        DataTable results = new DataTable();

        try
        {
            using (SqlConnection conn = new System.Data.SqlClient.SqlConnection("context connection = true"))
            using (SqlCommand command = new SqlCommand(query, conn))
            using (SqlDataAdapter dataAdapter = new SqlDataAdapter(command))
                dataAdapter.Fill(results);

            DataRow dummyRow = results.NewRow();

            dummyRow[0] = "1234";
            results.Rows.Add(dummyRow);

            return results.Rows;

        }
        catch (Exception e)
        {

        }

        return null;


    }

    public static void FillCLRTest(Object 

Open in new window

0
I am iterating through a text file using VB.net. Some of the numeric values are stored as strings. I would like to use the VB.net command Convert.ToSingle to convert the string input into a decimal(Or floating point number). How shall I handle the case when the string value is not numeric, because an exception will be thrown? I wish there was a command that could in effect look ahead to determine if the value is not numeric.



Dim num As Single
num - Convert.ToString(inString) ' Exception thrown here if the inString value is not numeric
0
I have a feeling I might be going about this the wrong way. I'm hoping there's a solution to what I want to accomplish.

I have the following colors defined in a resource dictionary
    <SolidColorBrush x:Key="Add.Border" Color="#FF4BAE53"/>
    <SolidColorBrush x:Key="Add.Background" Color="#FF5BB862"/>
    <SolidColorBrush x:Key="Add.Hover" Color="#FF439D4B"/>
    <SolidColorBrush x:Key="Add.Pressed" Color="#FF38843E"/>
    <SolidColorBrush x:Key="Add.Disabled" Color="#A55BB862"/>
    <SolidColorBrush x:Key="Add.Foreground" Color="White"/>

    <SolidColorBrush x:Key="Edit.Border" Color="#FFECA040"/>
    <SolidColorBrush x:Key="Edit.Background" Color="#FFEEAC55"/>
    <SolidColorBrush x:Key="Edit.Hover" Color="#FFEA952E"/>
    <SolidColorBrush x:Key="Edit.Pressed" Color="#FFD38323"/>
    <SolidColorBrush x:Key="Edit.Disabled" Color="#A5EEAC55"/>
    <SolidColorBrush x:Key="Edit.Foreground" Color="White"/>

    <SolidColorBrush x:Key="Delete.Border" Color="#FFD33B3B"/>
    <SolidColorBrush x:Key="Delete.Background" Color="#FFD85050"/>
    <SolidColorBrush x:Key="Delete.Hover" Color="#FFC82B2D"/>
    <SolidColorBrush x:Key="Delete.Pressed" Color="#FFAA2526"/>
    <SolidColorBrush x:Key="Delete.Disabled" Color="#A5D85050"/>
    <SolidColorBrush x:Key="Delete.Foreground" Color="White"/>

Open in new window

I'm creating a custom control that will use these colors as a palette. The actual colors it will use will be determined by a property I'm calling "Purpose". That purpose will be Add, Edit, or Delete. I already have that property working. What I don't have working is being able to select the Delete.Background color if the value of "Purpose" is Delete vs. the Add.Background color if the value is Add. Is this even possible? Is there perhaps another way I should be defining my colors in the resource dictionary to make this work properly?
0
Using Microsoft .NET Framework Version 4.8.03752 I performed a [successful] FTP upload.  How do I compare the source and the target to verify they match?
1
I have a VB.NET 2015 program that has a Tcp socket Listener and client applications to send messages to workers by their ip address.
I need to be able to pick up a file from a directory and send the text files data to a client machine connected to the listener. The file name is the ip address. When the file gets put into the directory is when the listener will pickup the file and send it to the appropriate ip address. I can pickup the file but the message gets sent to all clients connected to the listener.  My code is below.

Imports System.IO
Imports System.Net
Imports System.Net.Sockets
Imports System.Drawing.Size
Imports System.Net.IPAddress
Imports Microsoft.VisualBasic.FileSystem
Imports System.Windows.Forms
Imports System.ComponentModel




Public Class Form1
    Public watchfolder As FileSystemWatcher
    Dim ServerStatus As Boolean = False
    Dim ServerTrying = False
    Dim Server As TcpListener
    Dim Clients As New List(Of TcpClient)

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        CheckForIllegalCrossThreadCalls = False

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        StartServer()
        'Dim CN_GetData2015 As New CN_GetData2015
        'CN_GetData2015.Show()
        Button3.PerformClick()

    End Sub

    Function StartServer()
        If ServerStatus = False Then
            ServerTrying = True
            Try
                Server = New 

Open in new window

0
Hi,
How do i pick up the default printer and print the image in the picture box.
I am using vb.net
0
I'm still learning the mechanics of this whole WPF thing. I'm creating a user control. One of the things I want my control to be able to do is respond to click events of a control on the parent window. To do this, I have created a property called "Activator" like this:
		public DependencyObject Activator { get; set; }
		public static readonly DependencyProperty ActivatorProperty = DependencyProperty.Register("Activator", typeof(DependencyObject), typeof(NavView));

Open in new window

I then markup my Xaml like this:
                <Button Name="buttonShowHideMyControl" Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Right" Style="{DynamicResource HeaderButton}" Grid.ColumnSpan="2" Margin="0,4,9,0">
                    <fa:FontAwesome Grid.Column="2" Icon="Bars" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="White" FontSize="24" Margin="10,4,0,4"/>
                </Button>
            <local:TestUserControl x:Name="testUC" Grid.Column="1" HorizontalAlignment="Right" Visibility="Hidden" Opacity="0" Activator="{Binding Property, ElementName=buttonShowHideMyControl}">
                
            </local:TestUserControl>

Open in new window

0
Can you please tell me why this routine is not showing values in the text box when i click in the text area?
screenshot.JPG
      private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListBox i = sender as ListBox;
            if (i.SelectedIndex != -1)
            {
                listBox1.SelectedIndex = i.SelectedIndex;
                listBox2.SelectedIndex = i.SelectedIndex;
                txtID.Text = listBox1.SelectedItem.ToString();
                txtName.Text = listBox2.SelectedItem.ToString();               
            }
        
        }

Open in new window

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace InsertUpdateDel
{
    public partial class Form1 : Form
    {
        SqlConnection cn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Lenovo\Documents\Visual Studio 2012\Projects\InsertUpdateDel\InsertUpdateDel\Database1.mdf;Integrated Security=True;User Instance=True");
        SqlCommand cmd = new SqlCommand();
        SqlDataReader sd;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
                cmd.Connection = cn;
                loadlist();
        }

        private void button1_Click(object sender, 

Open in new window

0
Can you please help me in that error?
screenshot.JPG
namespace InsertUpdateDel
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.txtID = new System.Windows.Forms.TextBox();
            this.txtName = new System.Windows.Forms.TextBox();
            this.button1 = new System.Windows.Forms.Button();
            this.listBox2 = new System.Windows.Forms.ListBox();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            

Open in new window

0
Can you please help me in that error?
Error in List Box[code]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace InsertUpdateDel
{
    public partial class Form1 : Form
    {
        SqlConnection cn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Lenovo\Documents\Visual Studio 2012\Projects\InsertUpdateDel\InsertUpdateDel\Database1.mdf;Integrated Security=True;User Instance=True");
        SqlCommand cmd = new SqlCommand();
        SqlDataReader sd;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
                cmd.Connection = cn;
                loadlist();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (txtID.Text != "" & txtName.Text != "")
            {
                cn.Open();
                cmd.CommandText = "Insert into info(id, name) values ('" +txtID.Text+"', '" +txtName.Text+"')";
                cmd.ExecuteNonQuery();
                cmd.Clone();
                MessageBox.Show("Record Inserted", "Programming");
                cn.Close();
                txtID.Text="";
                txtName.Text="";
                loadlist();
            }
        }
        …
0
Can you please tell me what this error means?

Error statement: sd = cmd.ExecuteReader();

screenshot.JPG
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace InsertUpdateDel
{
    public partial class Form1 : Form
    {
        SqlConnection cn = new SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Lenovo\Documents\Visual Studio 2012\Projects\InsertUpdateDel\InsertUpdateDel\Database1.mdf;Integrated Security=True;User Instance=True");
        SqlCommand cmd = new SqlCommand();
        SqlDataAdapter sd;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
                cmd.Connection = cn;
                loadlist();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (txtID.Text != "" & txtName.Text != "")
            {
                cn.Open();
                cmd.CommandText = "Insert into info(id, name) values ('" +txtID.Text+"', '" +txtName.Text+"')";
                cmd.ExecuteNonQuery();
                cmd.Clone();
                MessageBox.Show("Record Inserted", "Programming");
                cn.Close();
                txtID.Text="";
                txtName.Text="";
                loadlist();
            }
        }

Open in new window

0
Using VS 2012 Professional.  Can't build a winforms application.  

Receiving error:  "Couldn't process file xxxx.resx due to its being in the Internet or Restricted zone or having the mark of the web on the file.  Remove the mark of the web if you want to process these files".

I tried adding to the local intranet -> file://computername like example below but didn't work.  I also tried to right click, properties, but there was NO unblock checkbox.

https://developercommunity.visualstudio.com/content/problem/291761/couldnt-process-file-abcresx-due-to-its-being-in-t.html

Any idea how to resolve.  This is a production problem for me.
0
I have a checkbox panel and I am adding the text for check box like this

chkPanel.Controls.Add(new CheckBox { Text = "Savings" + "This text needs to be red and bold", Checked = true, Enabled = false });
chkPanel.Controls.Add(new LiteralControl("<br />"));
chkPanel.Controls.Add(new CheckBox { Text = "Checking" , Checked = false, Enabled = false });


where you see "This text needs to be red and bold"  i actually want that text to be red and bold.  is it possible. if yes how?
0
In visual studio 2019  how to set auto incrementing build number or version number.
Thanks
0
Is "odeskwork" a freelancing website completely separate from "upwork"?  

Can USA freelancers join odeskwork site?
0
Forgive my ignorance. I'm still learning xaml.

I have this button:
                <Button Name="CloseButton" DockPanel.Dock="Top" HorizontalAlignment="Right" Style="{StaticResource TitleBarButton}" Click="CloseButton_Click" Tag="Images/Window/close.png">
                </Button>

Open in new window

This is the style definition I have so far:
    <Style x:Key="TitleBarButton" TargetType="Button">
        <Setter Property="Width" Value="34"/>
        <Setter Property="Height" Value="26"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="1,0,1,1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border x:Name="border" Background="Transparent" BorderBrush="Transparent" BorderThickness="1,0,1,1" >
                        <Image Source="{Binding Tag, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Button}}}" Stretch="None"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="border" Storyboard.TargetProperty="Background.Color" To="#FFFFFCF4" Duration="0:0:0.2"/>
                          

Open in new window

1
Hi
In the code bellow I'm getting null because the profile path in the database can be  null

How do I test for this so it dosn't throw a  NullReferenceException

as can be seen in the picture person isn't null person.JPG

        public ActorBox(person person)
        {
            InitializeComponent();
            this.person = person;
            if( (person.profile_path.EndsWith( "JohnWayneBig.png")) || ( person.profile_path is null) )
            {
                ThumbPhotoPath = ImgPath + "JohnWayneSml.png";
                FullPhotoPath = ImgPath + "JohnWayneBig.png";

            }
            else
            {
                ThumbPhotoPath = ImgURL + "w45" + person.profile_path;
                FullPhotoPath = ImgURL + "original" + person.profile_path;
            }
            

            ThumbPictureBox.LoadAsync(ThumbPhotoPath);
            ActorNameLbl.Text = person.name;
        }

Open in new window



System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=FilmsDB
  StackTrace:
   at FilmsDB.ActorBox..ctor(person person) in D:\Vb\MovieDB\FilmsDB\ActorBox.cs:line 34

Open in new window

0
I have added a new project to Team Foundation server(Source Control Explorer). I have not checked it in though. The new project and code has a litter green plus sign next to it.

So if I have not checked in the code yet, can I delete the code which was added in Source Control Explorer?
0
Using VB.NET  (Visual Studio 2019) in windows form how I can update the app.config file?  somebody know an example
0
I have a high throughput c# console app which is saving around 250-350 records a sec to a log table (sql server 2017 enterprise)

We are looking at ways to increase performance and sometimes a report is run on the table and things grind to a halt
We are also struggling to keep up at busy times

We currently do not use partitions, and are investigating this
We also insert one record at a time, and attach the insertedID to the c# object of log data for further operations

I'm considering partitions, however i'm not sure what to partition on hour, day, week month
We generally store 6 months of historical data (could also be 1 month or 24 months for smaller number of IOT devices.)
data is usually queried by day, last 7 days, week, month, and sometimes custom date ranges.
I would welcome ideas and comments about what is the best option here, we write more than we query, but queries will span multiple days/weeks

I'm also considering a different approach on inserting, instead of one at a time, do a batch insert.
However i'm unsure how I can then associate the database insertedID with C# object.
Currently its one at a time, so i just add the insertedID to the object, and send that off to messages queues for further processing,

I was looking at the SQL OUTPUT and inserted.ID but not sure when batching 500 records how to marry the inserted ID with the c# object

So in summary I would welcome ideas on
1) partition setup
2) batching inserts and marrying the …
0
Hello,
In a datetime field how do I determine if the time is between
00:00  to 2:45

example:
Datetime Field :  23/09/2019 00:15
The value is between 00:00  to 2:45
 and should return true

example2:
Datetime Field :  23/09/2019 01:15
The value is between 00:00  to 2:45
 and should return true


example3:
Datetime Field :  23/09/2019 02:46
The value is not between 00:00  to 2:45
 and should return false
0
Set datacolumn to date in vb.net
0
Hi All

As mentioned in Internet, LiteDB dll can be used with Dot Net Framework 3.5 but I am facing issue while doing same though the LiteDB dll is working fine with framework 4.0. Can anyone guide on same?

I am trying to use DLL Version 4.1.4.0.

Thanks.
0

.NET Programming

134K

Solutions

39K

Contributors

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.