|
I want to know how to control windows audio with C#
|
|
|
|
|
When your question is that broad, your best bet is google.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
This is my first time trying to work with a database. Let me explain what I've done real quick, then post my code, and you can tell me how I'm retarded. (Please)
First, I added an existing database to the project as a new data source. I did not have it automatically generate a typed dataset.
Next, in the design window, I added an untyped dataset to my form window. Then I placed a datagridview object in the window.
Under the DataGridView properties, I set the datasource to my untyped dataset.
I then modified my form code, as so:
<br />
public partial class PTAnalyzer : Form<br />
{<br />
public OleDbConnection conn;<br />
public OleDbDataAdapter dAdapter;<br />
public DataSet dSet;<br />
public string conString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\..\\ptrack6.mdb";<br />
<br />
public PTAnalyzer()<br />
{<br />
InitializeComponent();<br />
<br />
try<br />
{<br />
conn = new OleDbConnection(conString);<br />
dAdapter = new OleDbDataAdapter("SELECT * FROM game WHERE player_id = 11", conn);<br />
dSet = new DataSet();<br />
dAdapter.Fill(dataSetPT, "game");<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show("Error : " + ex.Message);<br />
}
}<br />
}<br />
<br />
No errors, it runs fine. But nothing is displayed within the datagridview object. What am I doing wrong here? Thanks.
|
|
|
|
|
budidharma wrote: dSet = new DataSet();
//refreshes rows in the DataSet
dAdapter.Fill(dataSetPT, "game");
Did you mean dSet in that last line?
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
Sorry, that dSet isn't actually used. I should delete that line. The data set is "dataSetPT."
|
|
|
|
|
|
Sure. I'm using VS 2005 rc3. The code was autogenerated by the IDE.
Here's the entire two files, most was autogenerated, excluding the stuff I posted in that first post.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace PTAnalyzer
{
public partial class PTAnalyzer : Form
{
// DATA ACCESS CODE
public OleDbConnection conn;
public OleDbDataAdapter dAdapter;
public DataSet dSet;
public string conString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\..\\ptrack6.mdb";
public PTAnalyzer()
{
InitializeComponent();
// DATA ACCESS INITIALIZATION
try
{
conn = new OleDbConnection(conString);
dAdapter = new OleDbDataAdapter("SELECT * FROM game WHERE player_id = 11", conn);
dAdapter.Fill(dataSetPT, "game");
}
catch (Exception ex)
{
MessageBox.Show("Error : " + ex.Message);
} //try-catch
}
}
}
namespace PTAnalyzer
{
partial class PTAnalyzer
{
///
/// Required designer variable.
///
private System.ComponentModel.IContainer components = null;
///
/// Clean up any resources being used.
///
/// <param name="disposing" />true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (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.dataSetPT = new System.Data.DataSet();
this.dataGridViewResults = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataSetPT)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataGridViewResults)).BeginInit();
this.SuspendLayout();
//
// dataSetPT
//
this.dataSetPT.DataSetName = "PTDataSet";
//
// dataGridViewResults
//
this.dataGridViewResults.AutoGenerateColumns = false;
this.dataGridViewResults.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridViewResults.DataSource = this.dataSetPT;
this.dataGridViewResults.Location = new System.Drawing.Point(12, 47);
this.dataGridViewResults.Name = "dataGridViewResults";
this.dataGridViewResults.Size = new System.Drawing.Size(654, 325);
this.dataGridViewResults.TabIndex = 0;
//
// PTAnalyzer
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(678, 384);
this.Controls.Add(this.dataGridViewResults);
this.Name = "PTAnalyzer";
this.Text = "PT Analyzer";
((System.ComponentModel.ISupportInitialize)(this.dataSetPT)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataGridViewResults)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Data.DataSet dataSetPT;
private System.Windows.Forms.DataGridView dataGridViewResults;
}
}
|
|
|
|
|
Specifically, in the second file, this is where the datagridview's datasource is set.
this.dataGridViewResults.DataSource = this.dataSetPT;
Really though, I'm trying to stumble through this and have no idea what I'm doing.
|
|
|
|
|
Finally just figured it out. I had to specifically set the datagridview datasource to a table index contained within the dataset. I was just setting it to the dataset.
|
|
|
|
|
Please can anyone tell me how to create Windows Services and deal with it(installing and running) coz it's not clear in the MSDN,
and there's another issue,
i want to make a Windows Service that let me control the Audio Volume of the Windows via short cut keys(like: Fn+UP or FN+DOWN),
how can i make it via C# and specialy in Windows Services....
thanks in advance.
|
|
|
|
|
|
Just a question, probably something easy...
I have a tab control setup with a user control in the tab. I want to have it so when a user makes their selection in the user control it will change tabs and load information in the new tab based on their selection... how would i reference the tab control from the user control? any thoughts? Thanks!
|
|
|
|
|
In my opinion, this is backwards. Your user control should be ignorant of its container, just like all of the other standard WinForm controls.
A better approach would be to have your user control raise an event when a selection was made. Your form would then catch that event and then change the tab selection.
|
|
|
|
|
Hmm, ok... do you know of anywhere with examples of how to do that?
|
|
|
|
|
|
Thanks in advance to those helping me. I'm somewhat of a novice, so possibly these questions are very trivial. I sure hope so!
I have a C# application that is generally instantiated by Internet Explorer / Mozilla, when a user downloads a filetype with my extension, then the application is called.
Unfortunately, the file downloaded by the browser is usually run from a temporary location, but this location depends on a number of factors, both by what type of browser. I need to process these files and save them for later, but unfortunately, since I don't know exactly where "here" is, I don't know where to look for them.
What I'd really like to do is figure out where my application is installed e.g., c:\Program Files\My Company\My Application\. But, since the user can type in any application during the install process, I can't just hard-code the path.
There has to be a place where that info is stored (My install application is a Visual Studio Deployment Project). Anyone know how to get to that?
If for some reason that's impossible, the next best option is to get the path to the current working directory.
|
|
|
|
|
|
private void loadRegimes()
{
XmlDocument document=new XmlDocument();
document.Load(xmlRegimes);
XmlNodeReader reader=new XmlNodeReader(document);
int standno=0,age=0,polygonno=0;
double acres=0;
ArrayList regimesList; //holding regimes for each stand
ArrayList regimeList; //hold ac cf wf data of regimes, ac cf wf data
ArrayList regimeObjList;//hold objetive value of each regime
int flowtype=0, flow=0, period=0;
string temStr;
while (reader.Read())
{
switch(reader.NodeType)
{
case XmlNodeType.Element:
switch(reader.LocalName)
{
case "stand": //cr
............................
Because the xmlRegimes is very large, the program get stucked, Is there a better way to load large xml file?
Thanks
|
|
|
|
|
There is.
The trouble with this approach is that you are loading the whole file into an XmlDocument, which keeps the whole thing in memory. You are then parsing this memory copy using a forward only reader.
Where possible, its better to stream the Xml in using XmlTextReader, this also is a forward only reader, but by using this you only deal with a tiny chunk of the whole document at a time. This is much prefered server-side as if you have multiple threads in your server each loading large xml documents in you could end up with a stressed server. This solution is far more scalable.
Regards,
Rob Philpott.
|
|
|
|
|
I was wondering if someone could point me in the right direction for creating a web component to an existing site, where an administrator could send the user messages. This is similar to etrade.com 's alerts or ebay's user inbox.. thanks!
MRH
|
|
|
|
|
Hello everyone, I was wondering are there any functions in ASP.NET that will allow you to pause for a few seconds like a sleep or wait function.
Thanks
TheMajorRager
|
|
|
|
|
Do you mean paues on the client or the server? If you're talking about pausing on the server then Thread.Sleep() might be what you're looking for. I'm sure there is a javascript equivalent for the client as well.
Can you give us some more context as to what you are trying to achieve?
Jared Parsons
jaredp@beanseed.org
http://spaces.msn.com/members/jaredp/
|
|
|
|
|
TheMajorRager wrote: I was wondering are there any functions in ASP.NET that will allow you to pause for a few seconds like a sleep or wait function
Not in the ASP.NET framework per se*. However, in the .NET framework (of which ASP.NET is a subset) there is <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemthreadingthreadclasssleeptopic.asp" rel="nofollow">Thread.Sleep()</a>[<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemthreadingthreadclasssleeptopic.asp" target="_blank" rel="nofollow" title="New Window">^</a>]
* Sorry, just being pedantic
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
Why would you want the server to sleep in the middle of building an HTML page for the client??
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Do you want to wait for some external process - or for an internal process to complete. If the latter you will need to look at threading and suspending a thread until an event or trigger occurs.
|
|
|
|