|
I have a button and the code on its this:
btnStartMnu.Image = System.Drawing.Image.FromFile("Themes\\WinME2\\WindowsMEButton1.bmp");<br />
Sound.Play("Sounds\\Camera.wav",PlaySoundFlags.SND_ASYNC);<br />
MessageBox.Show("Theme changed to Windows ME 2!", "Theme Changed");<br />
string appPath = Path.GetDirectoryName(Application.ExecutablePath);<br />
m_appSettings.Save(appPath + "\\Settings\\Settings.xml");<br />
m_saved = true;
When you click button, it changes its image and then saves the info in a XML file. What I want to know is how to add code so it will change the colour of a panel called pnlleft to red and panlright change its colour to yellow. How would you do this?
Also is there a way to change a fileMenu colours well?
In the end we're all just the same
|
|
|
|
|
Hey,
as long as you are in the same class you can simply use
pnlleft.BackColor = Color.Red;
(same with the other panel)
for the filemenu it is bit more complicate - the can only change the backcolor of one item - so the only way i know to change it all would be to go through every item.
|
|
|
|
|
i need a function that:
when i enter a date , function checks that format
if that format is correct return 1 and if not correct return 0;
and type of date field in database is not "date" its "varchar".
and my date is solar it's not of the Christian era.
thanks for your help
|
|
|
|
|
Create a DateTimeFormatInfo for the calendar you are using. Use that in the DateTime.Parse or DateTime.ParseExact method to parse the date. Use try...catch to catch the FormatException exception that occurs if the string format is incorrect.
---
b { font-weight: normal; }
|
|
|
|
|
How do bind a data using DataReader?
|
|
|
|
|
Hi,
First build a connection string and then initialise the command and reader object as
Write this in the event when you want it to be done:(i have used MSAccess as database)
OleDbConnection conn=new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\new1.mdb");
conn.Open();
OleDbCommand cmd=new OleDbCommand("select * from Table1",conn);
OleDbDataReader rdr=cmd.ExecuteReader();
rdr.Read();
DataGrid1.DataSource=rdr;
DataGrid1.DataBind();
This is a simple example..
YOu try out for more samples..
Feel free to ask anything regarding this..
|
|
|
|
|
hi
try this:
1. open connection
2. SqlCommand objSqlCommand = new SqlCommand();
3. SqlDataReader objSqlDataReader;
objSqlDataReader = objSqlCommand.ExecuteReader();
objSqlDataReader.Read();
grid.DataSource = objSqlDataReader;
grid.DataBind();
objSqlDataReader.Close();
3. close connection
|
|
|
|
|
Hello everyone,
Greetings from Brazil! As shown in the code below, is it possible for me to add the new objects for tipoDT and sementesDT without having to do it one-by-one? Like, for example, getting the values automatically from the tables?.... How would I do that? The sementesDT table is quite large and would take me forever to add the new objects one-by-one! Here's the code:
public frmBA()
{
tipoDT = new DataTable("tabTipoSemente");
tipoDT.Columns.Add("CodTipo", typeof(int));
tipoDT.Columns.Add("Tipo", typeof(string));
tipoDT.Rows.Add(new object[] { 0, "Nocivas Probidas" });
tipoDT.Rows.Add(new object[] { 1, "Nocivas Toleradas" });
tipoDT.Rows.Add(new object[] { 2, "Sementes Silvestres" });
sementesDT = new DataTable("tabSementes");
sementesDT.Columns.Add("CodSemente", typeof(int));
sementesDT.Columns.Add("CodTipo", typeof(int));
sementesDT.Columns.Add("Semente", typeof(string));
sementesDT.Rows.Add(new object[] { 0, 0, "SubCat0-Cat0" });
sementesDT.Rows.Add(new object[] { 1, 0, "SubCat1-Cat0" });
sementesDT.Rows.Add(new object[] { 2, 0, "SubCat2-Cat0" });
sementesDT.Rows.Add(new object[] { 3, 1, "SubCat3-Cat1" });
sementesDT.Rows.Add(new object[] { 4, 1, "SubCat4-Cat1" });
sementesDT.Rows.Add(new object[] { 5, 1, "SubCat5-Cat1" });
sementesDT.Rows.Add(new object[] { 6, 2, "SubCat6-Cat2" });
sementesDT.Rows.Add(new object[] { 7, 2, "SubCat7-Cat2" });
sementesDT.Rows.Add(new object[] { 8, 2, "SubCat8-Cat2" });
InitializeComponent();
tipoBS = new BindingSource();
tipoBS.DataSource = tipoDT;
TipoComboBoxColumn.DataSource = tipoBS;
TipoComboBoxColumn.DisplayMember = "Tipo";
TipoComboBoxColumn.ValueMember = "CodTipo";
unfilteredSementesBS = new BindingSource();
DataView undv = new DataView(sementesDT);
unfilteredSementesBS.DataSource = undv;
EspecieComboBoxColumn.DataSource = unfilteredSementesBS;
EspecieComboBoxColumn.DisplayMember = "Semente";
EspecieComboBoxColumn.ValueMember = "CodTipo";
filteredSementesBS = new BindingSource();
DataView dv = new DataView(sementesDT);
filteredSementesBS.DataSource = dv;
}
Thank you very much for your attention, time and help and I'm looking forward to your reply.
Best regards,
JC Carmo
|
|
|
|
|
JC Carmo wrote: Like, for example, getting the values automatically from the tables?....
What tables ? If you mean in a database, then yes, that's what a dataset is really for.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I mean the tabSementes table that is referenced in the code. How do I connect it to a DataSet ? Thanks for your reply.
JC.
|
|
|
|
|
A DataSet is a collection of DataTables, I'd assume you can create a datatable and add it to the Tables collection of a DataSet.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi Christian,
It's me again. I don't mean to be a drag, sorry about it, but I know how to connect to a dataSet in events such as form-load, but in this particular case, I'm a little lost, since the code I posted is part of teh code that filter values in comboboxes in a datagridview. Thanks a lot.
JC.
|
|
|
|
|
If you're copying an entire table, you can probably call it's Clone() method to create a copy and stuff it into a dataset. I'm guessing here tho. Why are you manipulating datasets and tables like this ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Dear All,,
Can U Help me to Generate the XML document from Excel Worksheet.Excel 2003 professional Edition have an option like XML in Data Menu..I have Excel 2003 Standard Edition...
Please Help me to get the Solution
Thanks n Regards,
Ramya.R
-- modified at 0:01 Friday 24th February, 2006
|
|
|
|
|
You can use dataset.GetXml method to get the xml
private const string xcel_CONN_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Excel 8.0;";
internal DataSet GetExcelDataToDataSet(string filepath, string sheetname)
{
OleDbConnection cn = null;
OleDbDataAdapter da = null;
DataSet ds = null;
try
{
cn = new OleDbConnection(string.Format(xcel_CONN_STRING, filepath));
cn.Open();
da = new OleDbDataAdapter(string.Format(xcel_sql, sheetname), cn);
ds = new DataSet();
da.Fill(ds);
return ds;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{
if(cn != null)
{
cn.Close();
cn.Dispose();
}
}
}
|
|
|
|
|
Hello
How to set DataGridViewButtonColumn 's Enabled ??
best wishes
hello
|
|
|
|
|
I m making an applicaiton that manages printing usin WMI calls. my appication looks like the queue similar to windows queu. There are 2 listboxes. 1 is showing printer name and the other is showing jobs associated with the selected printer in first listview.
on the selectedindex changed of listview1 i have filled listview2 the code for listview1 selected index changed is as follows:
string[] details = new string[12];
ListViewItem lv;
int i=0;
string a="";
Decimal size;
string submited_date;
try
{
a = this.listView1.SelectedItems[0].Text;
printername = this.listView1.SelectedItems[0].Text;
printerindex=this.listView1.SelectedItems[0].Index;
}
catch (Exception){}
try
{
this.listView2.Items.Clear();
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_PrintJob");
//listviewcolumes();
foreach (ManagementObject queryObj in searcher.Get())
{
System.String jobName = queryObj.Properties["Name"].Value.ToString();
char[] splitAr = new char[1];
splitAr[0] = Convert.ToChar(",");
string prntname = jobName.Split(splitAr)[0];
size = Convert.ToDecimal(queryObj["Size"].ToString());
string year = "";
string month = "";
string dates = "";
string hours = "";
string min = "";
string sec = "";
year = queryObj["TimeSubmitted"].ToString().Substring(0,4);
month = queryObj["TimeSubmitted"].ToString().Substring(4,2);
dates = queryObj["TimeSubmitted"].ToString().Substring(6,2);
hours = queryObj["TimeSubmitted"].ToString().Substring(8,2);
min = queryObj["TimeSubmitted"].ToString().Substring(10,2);
sec = queryObj["TimeSubmitted"].ToString().Substring(11,2);
//for (int x=0;x
|
|
|
|
|
Hi all,
I am developing a window application and have developed a menu. but i have to
add icons to menu items. pls tell me how this can be done. i am using c#.
Praveen.
|
|
|
|
|
|
You have answered your own question, actually.
If you create a boolean property inside a user control and then add the user control into a form (should be visible in the designer mode), then you can see the property in the Property Page of VS.NET editor.
There has to be more to life than just this
|
|
|
|
|
Hi,
I am a newbie to C# and Im trying to redirect standard input, output and error of a console program written in C (MS VC 6.0) to a textbox on a form. The code for the redirecting looks like this:
private System.IO.StreamWriter c_StreamInput = null;
private System.IO.StreamReader c_StreamOutput = null;
private Thread c_ThreadRead = null;
private Process c_Process = null;
private void ReadStdOutputThreadProc()
{
try
{
string str = c_StreamOutput.ReadLine();
while(str != null)
{
txtboxCNF.AppendText(str+"\r\n");
Thread.Sleep(100);
str = c_StreamOutput.ReadLine();
}
}
catch(Exception) {}
}
private void btnStart_Click(object sender, System.EventArgs e)
{
if(c_Process == null)
{
c_Process = new Process();
ProcessStartInfo psi = new ProcessStartInfo("console.exe");
psi.UseShellExecute = false;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;
psi.CreateNoWindow = true;
c_Process.StartInfo = psi;
c_Process.Start();
c_StreamInput = c_Process.StandardInput;
c_StreamOutput = c_Process.StandardOutput;
c_StreamInput.AutoFlush = true;
c_ThreadRead = new Thread(new ThreadStart(ReadStdOutputThreadProc));
c_ThreadRead.Start();
}
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (c_ThreadRead != null)
{
c_ThreadRead.Abort();
c_ThreadRead.Join();
}
if(c_Process != null && !c_Process.HasExited)
c_Process.Kill();
}
The console application that I am trying to run (console.exe) is a simple C program that prints a line text and then calls the getchar() function. The code is basically this:
#include "stdafx.h"
#include
int main(int argc, char* argv[])
{
printf ("Hello World !!\n");
int ch = getchar();
printf("Character = %s\n", ch);
return 0;
}
I have tried to run the C program without the getchar() function and it works. The problem arises when I use the getchar() function. I have tried getch() and gets() version without any success. I am not sure if I have to do anything special for showing output when using such functions.
Any help/pointers in this direction will be greately appreciated.
Thanks in advance.
Dribble
|
|
|
|
|
Ok should be a simple question as I didn't do research at all. (I'm tired, and been working all 15 hours on a coding project.) I would just like to know if there are any differences as far as connectors, queries and other coding related statements from SQL to MySQL. I am currently using MySQL to test the program, am I going to run into problems when making the final switch to SQL?
Thanks for all the help!
|
|
|
|
|
Hello,
If i am not mistaken, most probably you are asking about differece of queries between these two database engines.
If so, then here is my opinion.
The queries of MySQL is really different than SQL queries. Only very common queries will be same like, SELECT * FROM tableName, UPDATE tableName set ... etc., other than that, SQL queries are less forgiving than MySQL. In mySQL, joining table (inner join) , no need to mention in queries, like,
SELECT tableA.fieldA, tableB.fieldC from tableA,tableB WHERE tableA.id = 5 AND tableA.foriegnKey = tableB.primaryKey
But in SQL, you will have to use InnerJoin , ON etc phrase .
I know about parameters in SQL is @variable, in Access is , variable = ? , I dont know if mySQL has any parameter syntax to use in C#, as I used mySQL with PHP, not with anything else.
|
|
|
|
|
Thank you, usually I just use SQL, this time I am programming from home where I don't have access to a SQL server. Again, thanks for the quick response.
|
|
|
|
|
|