.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

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
Exploring SQL Server 2016: Fundamentals
LVL 13
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

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
Exploring ASP.NET Core: Fundamentals
LVL 13
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

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
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
I have a Async Function that references a control on the screen.  The control is updated with new information during the running of the function.  Do I place the Await Task.Delay(1) before or after the control is updated?

Btn.text = "One" : Await Task.Delay(1)

or

Await Task.Delay(1) : Btn.text = "One"
0
HOW WOULD YOU RESTRUCTURE THE DATA IN ACCESS or SQL SERVER IN ORDER TO EXECUTE THIS QUERY

QUERY--> "what is the effect of brain region, target location, and timing on kinematic response?"

ID      Parameter      UT_50      UT_0      UT_100      UT_250      MT_50      MT_0      MT_100      MT_250      LT_50      LT_0      LT_100      LT_250
20130318ED      DLPFC 100ms angle      12.32174145      12.99330841      9.198294504      11.52222631      6.340282729      5.765893345      2.356281523      2.816760675      15.21706611      11.67522974      37.53215703      28.62763514
20130415AV      DLPFC 100ms angle      6.643960487      2.681605064      45.47663277      13.03811801      11.46481681      11.70855284      16.70370681      21.46583857      4.024752731      20.52851436      12.07552518      18.812411
20130422PS      DLPFC 100ms angle      27.05474266      24.54031814      13.64629434      22.24167306      17.14609102      10.07054778      7.698115749      15.96791456      12.69933214      29.42852496      13.32754867      13.01389084
20130429AB      DLPFC 100ms angle      13.31082269      11.91017544      6.457531213      9.531094567      6.056097826      8.80621661      6.886299206      7.711310657      3.729936749      3.01717473      6.905232067      9.607273808
20130506JN      DLPFC 100ms angle      5.049545403      5.967528912      3.863780423      15.23849361      12.90741906      11.2606615      6.935865509      8.657818408      4.562420907      24.74435935      14.83554088      18.92366217
20130513WD      DLPFC 100ms angle      36.70301022      26.63866007      14.64716985      6.896767072      62.75687098      17.76465364      23.02631308      34.29193975      18.95470209      15.6362619      5.463278143      21.88485651
20130523VL      DLPFC 100ms angle      16.56186768      3.067840624      17.52907656      15.09035332      8.630383858      16.48188211      7.649123584      18.03464645      37.87583362      10.83250461      25.90015454      21.33974508
0
I'm creating a custom drawn form with its own title bar, footer, resizability, all that fun stuff. I've overridden the WndProc method of the form as follows:
		protected override void WndProc(ref Message m)
		{
			if (m.Msg == WM_NCHITTEST)
			{
				Point cursorPosition = new Point(m.LParam.ToInt32());
				cursorPosition = this.PointToClient(cursorPosition);
				Point resizeZone = new Point(this.FooterRectangle.Right - 16, this.FooterRectangle.Bottom - 16);
				System.Diagnostics.Debug.Print($"{resizeZone} - {cursorPosition}");
				if (cursorPosition.Y <= TITLEBAR_HEIGHT)
				{
					m.Result = (IntPtr)2;
					return;
				}
				if (cursorPosition.X >= resizeZone.X && cursorPosition.Y >= resizeZone.Y)
				{
					this.Cursor = Cursors.SizeNWSE;
					m.Result = (IntPtr)17;
					return;
				}
				else
				{
					this.Cursor = Cursors.Arrow;
				}
			}
			base.WndProc(ref m);
		}

Open in new window

This does a great job of allowing me to drag or resize the window but the one thing that's currently missing is being able to display the window context menu on either a right click or when left clicking on the form's icon in the upper left corner. (Screenshot attached for clarity). Can anyone tell me how this might be accomplished?
Window context menu
0
Hello,
Is there a better and faster way of Application.doevents
Thanks
0
CompTIA Cloud+
LVL 13
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

I have an ASP.NET Web Site built in .NET 4.7 using C#. In my web.config, I have the following Forms authentication (see web.config below) with the "domain" attribute set to ".mydomain.com" for my Production environment. Is there a way to dynamically change its value (via C#)  based on the environment, such as QA, Staging, etc. For example, if (Request.Url.AbsoluteUri.StartsWith("http://qa")), then I want to change the value of the "domain" attribute to ".myqadomain.com", and  if (Request.Url.AbsoluteUri.StartsWith("http://staging")), change the value to ".mystagingdomaincom".

Here's the <authentication> section of my web.config:
    <authentication mode="Forms">
      <forms path="/" name="MyWebSite_Auth" loginUrl="~/login.aspx" defaultUrl="~/customers/Default.aspx" protection="All" slidingExpiration="true" domain=".mydomain.com" timeout="350" cookieless="UseCookies"/>
    </authentication>

Please provide the necessary C# code to accomplish this.

Many thanks in advance.
0
When I say Clear Controls Recursively I mean resting text to empty strings and removing UserControl from flowLayoutPannel

The Picture bellow the blue is a panel inside this I have TextBoxes, Labels, tabControl & groupboxes
Inside the groupboxes there are TextBoxes, Labels, and RichTextBox These need resetting back to Empty strings

the tabControl has FlowLayoutPanel with UserControl

This Code finds child controls but doesn't find the grandchildren

I'm aware  I should probably use a switch rather than if / else if but I can't call it recursively I get error  

The name 'ClearMoviePanel' does not exist in the current context

Open in new window


CODE

//  To Call
        ClrearMoviePanel(MoviePanel.Controls);

        public void ClrearMoviePanel(Control.ControlCollection controls)
        {
            foreach (Control control in controls)
            {
                foreach (Control child in control.Controls)
                {


                    if (child.Name == TitleTxtBox.Name)
                    {
                        continue;
                    }
                    else if (child is TextBox || child is Label || child is RichTextBox)
                    {
                        child.Text = string.Empty;
                    }
                    else if (child is FlowLayoutPanel)
                    {
                        child.Controls.Clear();
                    }
                    else if(child.HasChildren)
                    {
  

Open in new window

0
I have an old MVC project that I want to upgrade/port to ASP.Net Core Web Applications. I've been reading some articles:

Ex: https://arghya.xyz/articles/porting-aspnet-apps-to-aspnet-core-2.0/

I created an ASP.Net Web Application Core. I run it and I get the first page. I click on Login and takes me to the login page. But, I don't see the login page in the project.
I did a search and I don't see it. I clicked on "show all files" but still don't see it.

See screenshots below:

e1.png
e2.png
0
Hi Experts,
 We have some excel files in particular folder. Currently we create the dashboard from excel files. We manually open file ,  remove duplication, apply some filters and copy some cell value and update the dashboard. We have to do for all the files for each row for dashboard.

We would like to automation for this requirement. Can you please suggest me any tool/solution ?

Should we use .Net application or VBA code?
0
Hello Experts,

I 'm new to JQuery and using Datatable(3rd party o plug-in) to show data(grid style) on the page. Once the record is inserted I want to update the grid(new record is inserted via button click which opens modal popup and later I'm refreshing the grid). But I'm getting "Not available" when destroying the datatable so I rebuild it again with new data. Below is the sample code.

HTML
<div class="table-responsive m-t-40">

                    <table id="dataTable" class="display nowrap table  dataTable" cellspacing="0" width="100%">
                        <thead>
                            <tr>
                                <th>First Name</th>
                                <th>Last Name</th>                               
                                <th>Phone</th>
                                <th>Email</th>                              
                            </tr>
                        </thead>
                        <tbody id="tblbody"></tbody>
                    </table>
                </div>

Open in new window


JavaScript
 $("#tblbody").empty();

                            data = JSON.parse(data);
                           $('#datatable').datatable().destroy(); -- Error here on  on Quick watch the value is "not available"
                            
                             -- Rest of the code doesn't execute due to error     
                            var html = '';
                            for (var i = 0; i < data.length; i++) {
                                var obj = data[i];

                                html += '<tr>'
                                html += '<td>' + obj.FirstName + '</td>';
                                html += '<td>' + obj.LastName + '</td>';                             
                                html += '<td>' + obj.PhoneNumber + '</td>';
                                html += '<td>' + obj.Email + '</td>';                                                                 
                                html += '</tr>'
                            }

Open in new window


If I comment $('#dataTable').DataTable().destroy() and try the above code I get a Warning message(popup) on the page and also tried $('#dataTable').DataTable().clear() it doesn't throw error but I got the same warning. Attached is the warning message.

Thanks,
ASPDEV
0
How to query or just get few columns a existing datatable to generate a new datatable of the result set.

Regards
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.