|
I have 1 form, 1 class and 1 table(from access).
I loaded the info from the table into the class and then added it all to an array list(on the form).
Now on the form i have a list box, with city names(which comes from the dataTable), nd in the dataTable i have some numbers next to each city name.
My question is how can i access these numbers that are stored in my arrayList to put into a formula(or to display when i select a city from the list).
If some can help me i would really appreciate it - this is really important.
|
|
|
|
|
The ListBox can hold any object in its list. You could do something like the following:
listBox.Items.Add( new City( cityName, cityNumber ) );
public struct City
{
public City( string name, int number )
{
this._name = name;
this._number = number;
}
public override string ToString()
{
return name;
}
public string CityName
{
get
{
return this._name;
}
}
public string CityNumber
{
get
{
return this._number;
}
}
} Then, later on, when someone has selected something in the list and you want to know what it is, you can use the following:
City c = ( City ) listBox.Items[ listBox.selectedIndex ]; You can then access the number stored in your City structure.
You can see an example of using this in my article Building the CVS Root File Changing Utility where I store a filename and CVS Root value in each item of the list so that I can later retrieve the information when someone clicks a button.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hey thanks alot that worked...i got a project due tomorrow.
T hanks alot for your help, really appreciate it.
|
|
|
|
|
I like the fact that I could help. Happy coding!
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hello,
I created a dataGrid based on a parameter query, on the same form of the dataGrid there is a comboBox with values. when I change the selection in the combo I want the DataGrid to change accordingly.
on SelectedIndexChange event for the combo, I send the value as a parameter to the dataAdapter, then fill the dataSet and refresh the dataGrid.
for some reason the grid is not refreshed.
this is my code:
private void re()
{
oleDbDataDetail.SelectCommand.Parameters.Add ("@vak",OleDbType.Integer ).Value=int.Parse(comboBox1.Text );
dataSetDetail.Clear();
oleDbDataDetail.Fill(dataSetDetails);
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{re();
dataGrid1.Refresh ();
}
any ideas?
Thank You!!!
|
|
|
|
|
If I am not mistaking your code will add a suplientary parameter (named "vak") every time a new item is selected in the combo box. But adding I don't think it will replace the old one, it jut will ad a new one. So when you are querrying the database, the result comes from the old (firs seted) parameter.
try using
oleDbDataDetail.SelectCommand.Parameters["@vak"] = int.Parse(comboBox1.Text );
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
Hi,
Thanks.
I tried that, but I get a converting type error.
I tried without parsing the value to int, but it doesnt work.
any ideas on how to fix the problem?
thank u!
|
|
|
|
|
The basic ideea is to create your command, add a parameter to it (the parameter must corespond to the database's right value type) and change the parameter value (adding by reference) every time you querry.
If you've done this and still recive erors, in order to be helped post them ...
protected internal static readonly ... and I wish the list could continue ...
|
|
|
|
|
Thank you.
I once added the parameter (on load form)
and then assigned a value to it.
Paramters["@vak"].value =.. ...
Thanx again!
|
|
|
|
|
i load a report in CrystalReportViewer.
i want to scroll down by pressing page down, but this event it's not handle by crystalReportViewer.
i used before Crystl32.OCX or Crystal control 9 , with these two control i could scroll down by pressing page down.
Need help ASAP
thx
|
|
|
|
|
Hello,
I am new here as far as posting goes.
Maybe someone can see what I'm Missing.
1)I am Getting Invalid Token @ (Account); - DisplayComposeForm(Account);
2)Member Modifier must precede the member type and name for "new" in the PictureBox1 -
3)For "Bitmap" -
(Class Struct, or interface must have a return type.
4)Identifier Expected - for -
string[] attachments = new string[] { cameraDialog.filename};
Does anyone see anything wrong here?
string account = "ActiveSync";
string to = "";
string subject = "";
string body = "";
string[] attachments = new string[] { cameraDialog.filename };
Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.DisplayComposeForm(Account);
Label1 text = "Image sent sucessful";
PictureBox1.image new Bitmap(cameraDialog.filename);
This is straight from Neil Enns tut yet It doesn't seem to work.
I have run through the Blogging App Tut and for some reason I keep getting Build errors on this - Yet all Looks Correct?
Any suggestions?
Thanks =)
-- modified at 1:45 Sunday 27th November, 2005
|
|
|
|
|
Here is the full source.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.PocketOutlook;
namespace TOYOURSPACE
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void menuItem1_Click(object sender, EventArgs e)
{
Microsoft.WindowsMobile.Forms.CameraCaptureDialog cameraDialog = new Microsoft.WindowsMobile.Forms.CameraCaptureDialog();
cameraDialog.Owner = this;
cameraDialog.Title = "Take a Picture";
if ((cameraDialog.ShowDialog() != DialogResult.OK)(cameraDialog.FileName == ""))
{
return;
}
string account = "ActiveSync";
string to = "";
string subject = "";
string body = "";
string[] attachments = new string[] { cameraDialog.filename };
Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.DisplayComposeForm(Account);
label1.Text = "Hello Windows Forms!";
PictureBox1.image = new Bitmap(cameraDialog.filename);
}
}
}
Seems I am missing something - and I am fairly new to the C# smartphone Development.
It's Probably something very simple I'm overlooking.
|
|
|
|
|
hello, i have a question that i would really like to be answered as soon as possible. i don't know if this is possible. hopefully it is (if it isnt, let me know)
question 1-
is there a way i can find out where the mouse cursor is in relation to the screen resolution? for example, if the mouse is in the middle of the screen, return 50% (or just 50). if it is 1 quarter of the way over from the left side of the screen, return 25% (or just 25), etc.
question 2-
is there a way i can SET where the cursor is, in relation to the screen resolution. for example, if i have the number 50% (or just 50), move the mouse to the middle of the screen. if the number is 25% (or just 25), move the mouse to 1 quarter over from the left side of the screen.
doesnt matter if it returns or sets with 25% or 25. if someone answers this i will be very grateful!
thanks very much,
sam kline
http://dying.about.com/gi/pages/poll.htm?poll_id=2068629450
YES
|
|
|
|
|
There are two main classes that could help you accomplish your goal
System.Windows.Forms.Screen
System.Windows.Forms.Form.MousePosition
These two classes work in screen coordintes.
Let's assume that all your processing is done in the only display of your computer, then a method that can give you the "relative mouse position" can be like this :
public void GetMouseRelativePosition(out double x, out double y) {
Size screenSize = new Size();
Point mousePosition = new Point();
screenSize.Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
screenSize.Width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
mousePosition.X = System.Windows.Forms.Form.MousePosition.X;
mousePosition.Y = System.Windows.Forms.Form.MousePosition.Y;
x = ((double)mousePosition.X / screenSize.Width) * 100;
y = ((double)mousePosition.Y / screenSize.Height) * 100;
}
In order to set your "relative position" you have to make your own method which recives the relative poition and set's the mouse coursor position.
Good luck!
protected internal static readonly ... and I wish the list could continue ...
-- modified at 3:08 Sunday 27th November, 2005
|
|
|
|
|
|
Why not?
Because you may want to know that the mouse is at a relative position of 45,638233%/13,2321334% instead of 46%/13%.
|
|
|
|
|
|
that worked! thanks very much, it really helped me!
sam kline
http://dying.about.com/gi/pages/poll.htm?poll_id=2068629450
YES
|
|
|
|
|
I need to get a list of local Users on a Windows XP machine. I do not need info from Active Directory. I also must get the user id from Windows and not from the Document and Settings Folder as the userid may or may not be mapped to a different profile. Any help is greatly appreciated.
|
|
|
|
|
Here's a method to get user ids.
string machineName = Environment.GetEnvironmentVariable( "COMPUTERNAME" );
DirectoryEntry entry = new DirectoryEntry( "WinNT://" + machineName );
ArrayList names = new ArrayList();
foreach( DirectoryEntry de in entry.Children )
{
if( de.SchemaClassName.Equals( "User" ) )
{
names.Add( de.Name );
}
} If you need more information that that, like human readable names, investigate the DirectoryEntry.Properties collection.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hello,
I want to use the value from a NumericUpDown control as one of the coordinates to
draw a line on a WinForm. I want to draw the line only when the button is clicked.
How do I tie all these fragments together?? Thanks a lot.
ps- Yes, I posted this question several days ago and was given a very good answer--
i.e. I should do all my drawing in the Paint Event handler, but I can't seem to tie the code fragments together....
//Fragment 1.
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics g = e.Graphics;
DrawMyLine(g);
}
//Fragment 2.
public void DrawMyLine(Graphics g)
{
g.DrawLine(somePen, 0, 0, 100, this.numericUpDown1.Value);
}
//Fragment 3. Want to draw line only if Button is clicked...
private void btnDrawA_Click(object sender, System.EventArgs e)
{
//??
}
//Fragment 4. Where do I fit in the bool flag?
Many thanks in advance......
|
|
|
|
|
Would something like this work?
private bool goAheadAndDrawTheLine;
private void Form1_Paint( object sender, System.Windows.Forms.PaintEventArgs e )
{
Graphics g = e.Graphics;
DrawMyLine(g);
}
public void DrawMyLine( Graphics g )
{
if( goAheadAndDrawTheLine )
{
g.DrawLine( somePen, 0, 0, 100, this.numericUpDown1.Value );
}
}
private void DrawA_Click( object sender, System.EventArgs e )
{
goAheadAndDrawTheLine = true;
}
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
-- modified at 20:55 Saturday 26th November, 2005
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
I'm doing a HTTPModule to summarize the text within web pages in my web server. The summarization process is with me but i need a big corpus of words to help on summarization.
My problem is : Where do i put this corpus in memory so it can be acessed quickly in runtime ????
Now i have a static variable that stay in memory with the corpus and the next time a page loads it has already the static corpus in memory. I have this static variable when i call HTTPModule. I still have the problem of loading the corpus in the first time that someone loads the page... I takes a while reading it from a file.
Is there any way to call my HTTPModule when the IIS starts or something like that???
Do you have any other ideas that can help me???
Where do i put the corpus in memory??? A Windows Service Works??? Can i call a Windows Service that has the corpus in memory and be fast enougth???
Thank you very much !!!
Sorry for my English...
Bruno Conde.
pharaoh
|
|
|
|
|
IDEA 1 - Object Serialization
If you have a lot of parsing going on when you read your corpus of words, you may think about loading a structure that has a serialization feature. You can load the corpus, serialize the object, and deserialize it. This should give you some performance benefit since you won't have to parse anything.
I did this for a financial analysis application. I would parse XML documents, store the information in the structures that I needed, then serialized them for use when the application restarted. It improved performance (memory usage and loading speed).
IDEA 2 - OnBeginRequestAsync
You could do the loading of your corpus in the OnBeginRequestAsync method. If needed, it would load in a separate worker thread and, when complete, could store the corpus in your static variable. While the corpus loads, any request that needed it could "wait" or inform the user that the summary feature is loading and will presently be available.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
hi,
After I do this:
ds.Tables["tbl"].find(key) (However the talbe is not sorted by "key" column)
and I get a DataRow,
How can I get the index of that row in table rows collection? (I know a sorted DataView find method can do this but here is not what I want, also, if I sort the "key" column, my original sort order will be lost). Any ideas?
(the table primary key column is "key", and sorted by column "userName". the nearst approach I can think of is I get the userName value by the "key" value, then I create a DataView with same sort order of the table, and I find that DataView with the userName value.)
Thanks!
|
|
|
|