|
WHat would the coding be to open an XML file when the application loads?
its saved in the applications folder under Settings\\Settings.xml
In the end we're all just the same
|
|
|
|
|
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("FILENAME.XML");
|
|
|
|
|
Thanks!
In the end we're all just the same
|
|
|
|
|
i write a function and i can not to call it
how can i call the fanction with btn_click.
private bool format(string date)
{
bool format;
if (date == "1384/04/03")
{
format = true;
}
else
{
format = false;
}
return format;
}
private void Button2_Click(object sender, System.EventArgs e)
{
date=txtdate.Text;
format(date);
}
|
|
|
|
|
The code you posted seems to be fine (it worked for my vs).
Could it be that the Button2_Click() Method isn't called.
Check the EventHandler for Button2 - there should be something like:
this.button2.Click += new System.EventHandler(this.Button2_Click);
|
|
|
|
|
i found the answer.
classname p= new classname();
p.format(date);
|
|
|
|
|
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.
|
|
|
|
|