Hi my name is vishal. I am converting my vb6 project(vb6,ado db with ms access) to c# with sql server 2008. I have a horizontal scroll bar in a form with some fields(labels,t extboxes,combob ox and datetime picker) such as first name, last name,sex,dob. what i expect from horizontal scroll bar is that when i scroll/move with horizontal scroll bar i want to see the datas that been in database(tables ) in the c# windows form. -
using System;
-
using System.Collections.Generic;
-
using System.ComponentModel;
-
using System.Data;
-
using System.Drawing;
-
using System.Linq;
-
using System.Text;
-
using System.Threading.Tasks;
-
using System.Windows.Forms;
-
using System.Data.SqlClient;
-
using System.Configuration;
-
-
namespace DRRS_in_Csharp
-
{
-
public partial class Technician : Form
-
{
-
long pUserID;
-
public Technician()
-
{
-
InitializeComponent();
-
}
-
-
private void Technician_Load(object sender, EventArgs e)
-
{
-
dtDOB.MaxDate = dtDOB.Value;
-
SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Tuscan16;Integrated Security=true");
-
if (conn.State != ConnectionState.Open)
-
{
-
conn.Open();
-
}
-
SqlCommand cmd = new SqlCommand();
-
cmd.Connection = conn;
-
cmd.CommandType = CommandType.Text;
-
DataTable dt = new DataTable();
-
string s1 = ("Select td.technician_first_name,td.technican_middle_name,td.technician_last_name,t.technician_dob,t.technician_sex,td.technician_type from TECHNICIANDETAIL td,TECHNICIAN t where td.technician_id=t.technician_id");
-
cmd = new SqlCommand(s1, conn);
-
if (dt.Rows.Count == -1)
-
{
-
scrRec.Visible = true;
-
long i = 0;
-
do
-
{
-
i = (i + 1);
-
} while (dt.Rows.Count == -1);
-
scrRec.Maximum = Convert.ToInt32(i - 1);
-
lblRecPos.Text = "Record Pos(1/" + i + ")";
-
txtFname.Enabled = false;
-
txtMname.Enabled = false;
-
txtLname.Enabled = false;
-
dtDOB.Enabled = false;
-
cboSex.Enabled = false;
-
txtFname.Text = cmd.Parameters.AddWithValue("technician_first_name", SqlDbType.VarChar).Value.ToString();
-
txtMname.Text = cmd.Parameters.AddWithValue("technician_middle_name", SqlDbType.VarChar).Value.ToString();
-
txtLname.Text = cmd.Parameters.AddWithValue("technician_last_name", SqlDbType.VarChar).Value.ToString();
-
dtDOB.Value = Convert.ToDateTime(cmd.Parameters.AddWithValue("technician_dob", SqlDbType.Date).Value);
-
if ((cmd.Parameters.AddWithValue("technician_type", SqlDbType.Int).Value is DBNull) && (Convert.ToBoolean(cmd.Parameters.AddWithValue("technician_type", SqlDbType.Int).Value == false.GetType())))
-
{
-
cmd.Parameters.AddWithValue("technician_type", cboTechType.SelectedIndex);
-
}
-
else
-
{
-
cboTechType.SelectedIndex = 0;
-
}
-
if (cmd.Parameters.AddWithValue("technician_sex", SqlDbType.VarChar).Value == "M")
-
{
-
cboSex.SelectedIndex = 0;
-
}
-
else
-
{
-
cboSex.SelectedIndex = 1;
-
}
-
}
-
else
-
{
-
scrRec.Visible = true;
-
button1.Text = "Create";
-
}
-
conn.Close();
-
}
-
-
private void button1_Click(object sender, EventArgs e)
-
{
-
if (button1.Text == "New")
-
{
-
txtFname.Enabled = true;
-
txtMname.Enabled = true;
-
txtLname.Enabled = true;
-
cboSex.Enabled = true;
-
dtDOB.Enabled = true;
-
-
txtFname.Text = "";
-
txtMname.Text = "";
-
txtLname.Text = "";
-
cboSex.SelectedIndex = -1;
-
txtFname.Focus();
-
button1.Text = "Create";
-
}
-
string dFieldName = "";
-
if (txtFname.Text.ToString().Trim() == "")
-
{
-
dFieldName = "Please enter the technician first name";
-
}
-
else if (cboSex.SelectedIndex == -1)
-
{
-
dFieldName = "Please select gender for technician";
-
}
-
else if (cboTechType.SelectedIndex == -1)
-
{
-
dFieldName = "Please select technician type";
-
}
-
if (dFieldName.ToString().Trim() != "")
-
{
-
MessageBox.Show(dFieldName);
-
}
-
SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Tuscan16;Integrated Security=true");
-
if (conn.State != ConnectionState.Open)
-
{
-
conn.Open();
-
}
-
SqlCommand cmd = new SqlCommand();
-
cmd.Connection = conn;
-
cmd.CommandType = CommandType.Text;
-
cmd = new SqlCommand("insert into TECHNICIAN(technician_dob,technician_sex,row_upd_date,user_id)" + "Values(@technician_dob,@technician_sex,GetDate(),@user_id)", conn);
-
if (cboSex.SelectedIndex == 0)
-
{
-
cmd.Parameters.AddWithValue("@technician_sex", SqlDbType.VarChar).Value = "M";
-
}
-
else
-
{
-
cmd.Parameters.AddWithValue("@technician_sex", SqlDbType.VarChar).Value = "F";
-
}
-
cmd.Parameters.AddWithValue("@technician_dob", dtDOB.Value);
-
cmd.Parameters.AddWithValue("@user_id", pUserID);
-
cmd.ExecuteNonQuery();
-
-
cmd = new SqlCommand("Insert into TECHNICIANDETAIL(technician_first_name,technician_middle_name,technician_last_name,row_upd_date,status,user_id,technician_type)" + "Values(@technician_first_name,@technician_middle_name,@technician_last_name,GetDate(),@status,@user_id,@technician_type)", conn);
-
cmd.Parameters.AddWithValue("@technician_first_name", txtFname.Text);
-
cmd.Parameters.AddWithValue("@technician_middle_name", txtMname.Text);
-
cmd.Parameters.AddWithValue("@technician_last_name", txtLname.Text);
-
cmd.Parameters.AddWithValue("@technician_type", cboTechType.SelectedIndex);
-
cmd.Parameters.AddWithValue("@status", true);
-
cmd.Parameters.AddWithValue("@user_id", pUserID);
-
cmd.ExecuteNonQuery();
-
((MDIParent5)this.MdiParent).updateUserActivities(pUserID, 3, txtFname.Text + "technician detail was added successfully");
-
MessageBox.Show("Technician detail was added successfully", "DRRS", MessageBoxButtons.OK, MessageBoxIcon.Information);
-
conn.Close();
-
-
-
}
-
-
private void button2_Click(object sender, EventArgs e)
-
{
-
this.Close();
-
}
-
-
private void scrRec_Scroll(object sender, ScrollEventArgs e)
-
{
-
-
SqlConnection conn = new SqlConnection("Data Source=NPD-4\\SQLEXPRESS;Initial Catalog=Tuscan16;Integrated Security=true");
-
if (conn.State != ConnectionState.Open)
-
{
-
conn.Open();
-
}
-
SqlCommand cmd = new SqlCommand();
-
cmd.Connection = conn;
-
cmd.CommandType = CommandType.Text;
-
DataTable dt = new DataTable();
-
-
lblRecPos.Text = "Record Pos(" + scrRec.Value + 1 + "/" + scrRec.Maximum + 1 + ")";
-
if (dt.Rows.Count == -1)
-
{
-
txtFname.Enabled = false;
-
txtMname.Enabled = false;
-
txtLname.Enabled = false;
-
dtDOB.Enabled = false;
-
cboSex.Enabled = false;
-
txtFname.Text = cmd.Parameters.AddWithValue("technician_first_name", SqlDbType.VarChar).Value.ToString();
-
txtMname.Text = cmd.Parameters.AddWithValue("technician_middle_name", SqlDbType.VarChar).Value.ToString();
-
txtLname.Text = cmd.Parameters.AddWithValue("technician_last_name", SqlDbType.VarChar).Value.ToString();
-
dtDOB.Value = Convert.ToDateTime(cmd.Parameters.AddWithValue("technician_dob", SqlDbType.Date).Value);
-
if ((cmd.Parameters.AddWithValue("technician_type", SqlDbType.Int).Value is DBNull) && (Convert.ToBoolean(cmd.Parameters.AddWithValue("technician_type", SqlDbType.Int).Value == false.GetType())))
-
{
-
cmd.Parameters.AddWithValue("technician_type", cboTechType.SelectedIndex);
-
}
-
else
-
{
-
cboTechType.SelectedIndex = 0;
-
}
-
if (cmd.Parameters.AddWithValue("technician_sex", SqlDbType.VarChar).Value == "M")
-
{
-
cboSex.SelectedIndex = 0;
-
}
-
else
-
{
-
cboSex.SelectedIndex = 1;
-
}
-
conn.Close();
-
}
-
-
i have tried coding for horizontal scroll bar but nothing seems to work. Can anyone help me please!
0 1215 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Nishant |
last post by:
I have a combo box with a horizontal scroll bar.
(Used SetHorizontalExtent)
The dropdown with horizontal scroll bar works fine when I have more
items in the dropdown list. However when the number of items is less,
the horizontal scroll bar comes over the last item.
If there is only one item, I am not able to see that item because of
Horizontal scroll.
|
by: Boaz Ben-Porat |
last post by:
Hi all
Is there a way to simulate a click on a scrollbar (horizontal) of a FataGrid
?
I need to programmatically scroll the grid to the right/left upon some
condition, when the total width of the grid columns is greater then the
grid`s rectangle.
TIA
|
by: André Nobre |
last post by:
hi all...
i have a listbox in a webform and i wanna know if there´s way to put
horizontal scroll in it. I tried HorizontalScrollbar = True, like windows
forms but it didn´t work.
Anyone can help me?
Thanks,
André
|
by: Vidds |
last post by:
Hi Everyone,
How come Server listbox control does not have a Horizontal Scroll Property?
If any one has an idea how we add a Horizontal scroll to a listbox or
dropdown list box it would be quite helpful.Thanks in advance
Regards
Vidds
|
by: Sam |
last post by:
I've researched and tried all the suggestions I've found and still
haven't been able to get the horizontal scroll bar to appear in my
combo box. I've tried setting the Column Widths property larger than
the Width property and set the List Width property to Auto as someone
suggested in another thread but it doesn't work. I give up. Please
help. If more info is needed let me know.
The rowsource is a simple query:
SELECT ANSWER_TEXT
| |
by: Steve |
last post by:
Hi All
I want to prevent the Windows Tabcontrol from showing the horizontal scroll
bar when the Number of Tabs exceeds the width of the control
I use code in 2 buttons to control the scrolling, as the default scroll
buttons are too hard to target on a Touch Screen
How do I do this?
|
by: Michael Richard |
last post by:
Hi,
I need a help from you. I'm writing device driver for 64 bit Windows Server 2008. I have code for 32 bit Windows Server 2008, its working fine on 32 bit.
I need a help to port from 32 bit to 64 bit.
Please help me out.
Thanks a lot.
|
by: =?Utf-8?B?Tml0cmFt?= |
last post by:
I have searched almost everywhere to find this info, but have not read it
anywhere. Can I use Web Server 2008 if the only thing it does is to host a
bunch of .PDFs for people to look at from the web? Using a SQL database, with
a bunch of PDFs, then people access it from the web, and view the files.
Isn't that using it properly?
|
by: amuven |
last post by:
Hi All,
I need to put a horizontal scroll bar for 4 cells alone where my first cell in table should not contain any horizontal scroll bar .
In clear, let us say there are 5 columns in my table i want to put horizontal scroll bar only for 2nd,3rd,4th and 5th column alone where my 1st column should not horizontal scroll bar . so that I can scroll only last 4 columns .
Please some one provide me sample code as early as possible in doing...
|
by: newbie009 |
last post by:
How can I disable horizontal scroll in textbox for FireFox?
Right now 1 textbox has vertical scroll and other textbox has horizontal scroll.
It only looks like this on FireFox but it looks ugly.
http://jumbofiles.com/example.gif
I used this code but it only worked for IE not FireFox:
style="overflow: scroll; overflow-y: scroll; overflow-x: hidden; overflow:-moz-scrollbars-vertical;"
Basically I want only vertical scroll.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |