|
|
Have an Access DB A table called Zips and Field called zipcodes. I can get the data at the console.writeline but the combobox shows nothing. Any ideas.
private void property_Load(object sender, System.EventArgs e)
{
string strDSN="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\\ARM1\\database\\utility.MDB;Jet OLEDB:Database Password=rival";
string strSQL="Select * FROM zips";
//Connection Object
OleDbConnection connection = new OleDbConnection(strDSN);
OleDbCommand MyCmd=new OleDbCommand(strSQL,connection);
connection.Open();
OleDbDataReader rsZips=MyCmd.ExecuteReader();
ArrayList load = new ArrayList();
while(rsZips.Read())
{
load.Add(rsZips["zipcodes"].ToString());
}
this.comboBox1.DataSource=load;
comboBox1.DisplayMember="zipcodes";
for (int cnt = 0; cnt < load.Count; cnt++)
{
string anItem = load[cnt].ToString();
comboBox1.Items.Add(anItem);
Console.WriteLine(anItem);
}
connection.Close();
}
TIA Jim
|
|
|
|
|
Hi Jimbo,
If you getting the data at the console, The combo box should also get populated.
I suppose u do not require the code line
this.comboBox1.DataSource=load;
since u are traversing the data using for loop.
comment the line of code(this.comboBox1.DataSource=load;
)
U will get the result.
Do revert back if u are still unable to solve.
Jay.
|
|
|
|
|
This didn't work. The combobox seems to be populated but nothing appears.
Here is the code for the whole form. Maybe this can shed some light. Jim
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using System.Text;
using System.Data.OleDb;
using System.Data;
namespace mdisample
{
///
/// Summary description for property.
///
public class property : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label2;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public property()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.label2 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// panel1
//
this.panel1.AutoScroll = true;
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.comboBox1);
this.panel1.Controls.Add(this.label1);
this.panel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.panel1.Location = new System.Drawing.Point(8, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(600, 300);
this.panel1.TabIndex = 0;
//
// label2
//
this.label2.Location = new System.Drawing.Point(144, 56);
this.label2.Name = "label2";
this.label2.TabIndex = 2;
//
// comboBox1
//
this.comboBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.Location = new System.Drawing.Point(288, 56);
this.comboBox1.MaxDropDownItems = 20;
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(216, 21);
this.comboBox1.Sorted = true;
this.comboBox1.TabIndex = 1;
//
// label1
//
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.Location = new System.Drawing.Point(248, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(304, 16);
this.label1.TabIndex = 0;
this.label1.Text = "Please select the Zipcode you are looking for.";
//
// property
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(680, 273);
this.Controls.Add(this.panel1);
this.Name = "property";
this.Text = "Property";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.property_Load);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/*================================================
* Directory scanner Not used because we bind to the DB
* ===============================================*/
void DirToLbox(string targetPath, ListBox myListBox)
{
// create an array to hold the subdirectories
ArrayList sArray=new ArrayList();
// create an array to hold the list of files
ArrayList fArray=new ArrayList();
// get information about our initial directory
DirectoryInfo dirInfo=new DirectoryInfo(targetPath);
// retrieve array of files & subdirectories
FileSystemInfo[] myDir=dirInfo.GetFileSystemInfos();
for (int i=0; i<mydir.length; i++)=""
="" {
="" check="" the="" file="" attributes
="" if="" a="" subdirectory,="" add="" it="" to="" sarray="" otherwise,="" farray
="" (((convert.tobyte(mydir[i].attributes)="" &="" convert.tobyte(fileattributes.directory)="" )=""> 0 ))
sArray.Add(Path.GetFileName(myDir[i].FullName)
+ "\\");
else
fArray.Add(Path.GetFileName(myDir[i].FullName));
}
// sort the subdirectories alphabetically
sArray.Sort(0,sArray.Count,null);
// sort the files alphabetically
fArray.Sort(0,fArray.Count,null);
// ensure that the listbox has no items beforehand
myListBox.Items.Clear();
// insert the sorted subdirectories into the listbox
for (int i=0; i
|
|
|
|
|
Hi Jimbo,
Comment the following line
<br />
this.comboBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;<br />
<br />
this.comboBox1.DrawMode = System.Windows.Forms.DrawMode.Normal;
the code will work.
In case if you are unable to get the result. Do revert back.
Regards,
Jay
|
|
|
|
|
I am making a screensaver of sorts and I am trying to detect when p,P, or escape key is pressed. When i would hit p the screensaver would stop but upon hitting p again it should have started up again but had no response so i changed it to this.
construct...
this.KeyUp += new KeyEventHandler(OnKeyPress); ...
public void OnKeyPress(object o, KeyEventArgs e) {
switch(e.KeyCode) {
case Keys.Escape:
Application.Exit();
break;
default:
break;
}
}
all the examples i was able to locate show using a frikin textbox... i just want the form to check and handle necessary actions required.
codemonkey
aspiring programmer
|
|
|
|
|
Hi
I do not know if I'm get it right but from what you say :
there is property of the form which when you set it to true also the form keypressed and key up key down raises .
frmMain.KeyPreview = true ;
then you can use form 's event to handle what you want.
|
|
|
|
|
Hi, im trying to get a image from a path.
foto is a string path espec. by the user.
FileStream f = new FileStream( foto, FileMode.Open ); <br />
Image img = Image.FromStream( f );
This doesnt working, its only works if the image is in the same folder of the program =/
Thanks.
|
|
|
|
|
Hi, im trying to get a image from a path.
foto is a string path espec. by the user.
FileStream f = new FileStream( foto, FileMode.Open ); <br />
Image img = Image.FromStream( f );
This doesnt working, its only works if the image is in the same folder of the program =/
Thanks.
|
|
|
|
|
MoOnBoY wrote:
Image.FromStream( f );
I think there is a better way!
Just use:
Image img = Image.FromFile("C:\\...");
Oh, and a little correction:
This doesnt working, its only works if the image is in the same folder of the program.
This doesn't work. Its only working if the image is in the same folder as the program.
;);) Just kidding ;););)
Good luck!
|
|
|
|
|
The path is specificated by the USER...
foto is the path, if I use: Image img = Image.FromFile( foto ); Only works if the path is the same of program folder....
|
|
|
|
|
Let's say we have a textBox called textBox1 .
And let's say we hava a picture box called pictureBox1 .
We use pictureBox1 to view the image.
The user types in the CORRECT path.
The user clicks on a button.
And now the button's OnClick event:
Image img = Image.FromFile (<font color=#0000ff>this</font>.textBox1.Text);<br />
<font color=#0000ff>this</font>.pictureBox1.Image = img;
Then add an error handling with TRY and CATCH.
I've already tested this code.
It MUST work.
|
|
|
|
|
If the path is specified by the user then use
Image img = Image.FromFile ( @foto );
|
|
|
|
|
as i understood that u ve image and u want to open it from stream file...
1-u cant use Image class as it is abstract one, so u cant define object from it
2-u use Bitmap class to open ur image
//example: dont forget to use (Using System.Drawing)
Bitmap myimage=new Bitmap(filestream,true);
//constructor use true to make error correction..hope it works
|
|
|
|
|
Hello,
I'm developing some windows based application. I have made a setup to deploy the application to some other computer. I want to deploy an application for only 15 days. Or you can say that i want to deploy an application as trail version of 15 days for testing purpose. After 15 days, application should be stoped working automatically. Hopefully, someone will understand my question and will reply me as soon as possible.
Thanks.
|
|
|
|
|
IF your are asking a question like this, i doubt anyone would buy the app. :\
|
|
|
|
|
Infact, i have to deploy the application for testing purpose to the company before the final deployment. So instead of giving me this answer, reply me the solution.
Thanks.
|
|
|
|
|
There are multiple ways and there are also a multitude of companies that make a living off of providing this type of solution. I don't think there is an easy solution that can be posted to the forum.
The easiest way would probably be using a registry key added upon instalation and some code in the app that checks the key and compares a date against a certain period of time.
Here are some long list of companies providing ready made components. I only see one open source one but there may be more.
http://dmoz.org/Computers/Software/Licensing/License_Management/
http://dmoz.org/Computers/Security/Products_and_Tools/Software_Protection_and_License_Control/
--------------------
It is what is is!
|
|
|
|
|
there are C++ examples, such as Nish's one[^] that do what you are asking, maybe you can port those over to C#.
To those who didn't make it, we will remember you. To those who did is back. - Megan Forbes in Black FridayAnother Post by NnamdiOnyeyiri
|
|
|
|
|
Hi
Is there any method by which I can make an app transparent...like even if it appears(not completely transparent), it should not respond to mouse clicks (say if the ctrl key wasnt pressed along with a mouse click) and should transfer the ctrl to the app behind it...
Example:
Letz a scoreboard display and behind it IE...u dont need any user triggered event for it...so even if i click in the display, IE should respond and not the display..
Is there any method in C#?
Thanks
|
|
|
|
|
Oh most definately, there is a property in the System.Windows.Forms.Form class! Make a form with these properties:
/////
this.TransparencyKey = System.Drawing.SystemColors.Control;
this.Opacity = .8;
/////
Setting the TRANSPARENCYKEY to that will make the form seem invisible. Not visibly, but... like you said, it makes it so when the user clicks, it responds to whatever is running behind it.
Setting the OPACITY makes it look invisible. Setting it to "1.0" makes it very slightly invisible, however, when set to ".1" you can hardly see it.
Hope this helps!
|
|
|
|
|
kewl thanks..ill try it...
|
|
|
|
|
But is it possible to get the controls to this transparent window when needed (like it shud respond whenever i click the mouse along with the ctrl key)...?? Because from what you said..it seems that windows will manage the ctrls and decide only based on opacity and not on programmer's setting right?
|
|
|
|
|
Here ya are! Best I can come up with so far! Any questions?
<br />
public class Joshua : Form {<br />
[STAThread]<br />
public static void Main() {<br />
Application.Run(new Joshua());<br />
}<br />
<br />
public Joshua() {<br />
this.ClientSize = new Size(520, 310);<br />
this.Name = "Form1";<br />
this.ShowInTaskbar = false;<br />
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;<br />
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;<br />
this.TopMost = true;<br />
this.TransparencyKey = System.Drawing.SystemColors.Control;<br />
this.Opacity = .8;<br />
}<br />
<br />
protected override void OnKeyDown(KeyEventArgs kea) {<br />
if(kea.KeyCode == Keys.ControlKey) {<br />
this.TransparencyKey = System.Drawing.Color.Empty;<br />
}<br />
}<br />
<br />
protected override void OnKeyUp(KeyEventArgs kea) {<br />
if(kea.KeyCode == Keys.ControlKey) {<br />
this.TransparencyKey = System.Drawing.SystemColors.Control;<br />
}<br />
}<br />
}<br />
<br />
|
|
|
|
|
Yo buddy..
tat works...need to build my app (it is just a cricket(a game) scorecard )..as existing ones occupy my desktop
thanks again pal...tat was one awesome quickness uve got!!
|
|
|
|