|
AFAIK there is no Select method in CheckBox class. Checked is the property you should use.
The word "politics" describes the process so well: "Poli" in Latin meaning "many" and "tics" meaning "bloodsucking creatures."
जय हिंद
|
|
|
|
|
if (SelectAll.Checked)
foreach (var checkBox in this.tableLayoutPanel1.Controls.OfType<checkbox>())
checkBox.Checked = true;
Eslam Afifi
|
|
|
|
|
The checkboxes are not on the form but on the panel.
this. is assumed if not specified so your code reads:
this.cb.Select();
If you try:
for (i = 0;i < many; i++)
{
string checkname = "cb" + i.ToString().Trim();
checkbox checkitout = (checkbox) this.NameOfPanel.Controls[checkname];
checkitout.Select() = true;
}
This is aircode, so please mind the caps. I also don't know what the Select() property is, but I'll assume you've defined your own checkboxes.
you also see that it is advisable to rename the first checkbox from cb to cb0.
succes !
|
|
|
|
|
Hi
i have a dagaridview view bind to an empty dataTable, user can insert values directly into datagridview and then click Save. when user clicked Save button, i write this code to iterate through dataTable records and insert to my database in transaction mode :
using (SqlConnection con = new SqlConnection("data source=.;initial catalog=test;Trusted_Connection=Yes"))
{
SqlCommand cmd = con.CreateCommand();
cmd.CommandText = "insert Person(titleId,fname,lname) values(@titleId,@fname,@lname)";
con.Open();
System.Transactions.TransactionOptions trOptions = new System.Transactions.TransactionOptions();
trOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
trOptions.Timeout = new TimeSpan(0, 0, 15);
using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, trOptions))
{
try
{
foreach (DataRow row in this.dt1.Rows)
{
int titleId = int.Parse(row["titleId"].ToString());
string fname = row["fname"].ToString();
string lname = row["lname"].ToString();
if (cmd.Parameters.Count > 0)
cmd.Parameters.Clear();
cmd.Parameters.AddWithValue("@titleId", titleId);
cmd.Parameters.AddWithValue("@fname", fname);
cmd.Parameters.AddWithValue("@lname", lname);
cmd.ExecuteNonQuery();
}
con.Close();
ts.Complete();
}
catch (Exception ex)
{
}
}
}
I want, all of insertion execute in transation, for test, at runTime i was entered correct row in first datagridview row and then entered incorrect row in second with cause exception, but at runTime the first records has been inserted wheras i want when error has occured, all inserted records rollback.
Can anybody help me ?
Thanks
|
|
|
|
|
Use BeginTransaction, Commit and Rollback methods in SQLTransactionClass.
The word "politics" describes the process so well: "Poli" in Latin meaning "many" and "tics" meaning "bloodsucking creatures."
जय हिंद
|
|
|
|
|
Hi d@nish
Yes i know this, but i want to do this by TransactionScope calss and i want to know where does my mistake and how to solve it ?
thanks
|
|
|
|
|
Hi,
Is there any way to avoid restricted method while iterating the method using GetMethods() and properties using GetProperties().
GetMethods() - Using Binding Flags we can filter public ,static,Instance methods.How tofilter out restricted methods.
Generealy Restricted methods are not available for macro progarmming language like VB.
Pls help me ...
By
Rajanbabu
Rajanbabu
|
|
|
|
|
rajanbabu_033 wrote: restricted method
?? You mean Private ?
Read this post Obfuscation[^]
|
|
|
|
|
Hi,
Please help me for the following issues.
In CSharp GetMethods() is returning all the methods and properties of particular Type instead method alone.
How to get the all the methods of particular Type?It should not contain any get,put properties.
I have a sample CSharp program here....
namespace ReflectionDemo
{
class MyClass
{
public void display()
{}
public int RegisterNumber
{
get
{
return 0;
}
set
{
}
}
class ReflectionDemoClass
{
static void Main(string[] args)
{
MyClass mc = new MyClass();
Type tt = mc.GetType();
MethodInfo[] methInfo1 = tt.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
foreach (MethodInfo mI1 in methInfo1)
{
string methodName = mI1.Name;
System.Console.WriteLine(mI1.Name);
}
}
}
output for this program is :
display
get_RegisterNumber
set_RegisterNumber
Above output have both methods and Properties
but i want to get output : display
Could anyone help me to get this answer(I mean only methods of MyClas not the properties)?
By
Rajanbabu
Rajanbabu
|
|
|
|
|
Hi,
You could use MethodInfo.IsSpecialName , so you'll get the methods only by checking (mI1.IsSpecialName == false )
Calin
|
|
|
|
|
Thanks a lot Calin.It's working fine.This solution is very much helpful for my project.
I have one more clarification also please help me if possible,
Issue :
I hope you are aware that restricted methods are not available for Visual basic users.
E.g.,
interface IFunctionParameterDemo : IDispatch
{
[id(1),restricted,helpstring("method Display")] HRESULT Display();
[id(2),helpstring("method Calculate")] HRESULT Calculate();
};
coclass FunctionParameterDemo
{
[default] interface IFunctionParameterDemo;
};
Here method Display() is marked as restricted by the attribute restricted.So we can't use this method from Visual basic(If we call this method from VB,during compile time it will show error as "Method or Interface marked as restricted")
In reflection is there any way to filter out these restricted methods?
Type t = GetType(FunctionParameterDemo);
MethodInfo[] mInfo = t.GetMethods();
foreach (MethodInfo m in mInfo)
{
System.Console.WriteLine(m.Name);
}
output:
Display()
Calculate()
But I want the output : Calculate()
using GetMethods() i want to get the result of Calculate()alone.It should filter out restricted method Display().
Regards,
M.Rajanbabu.
|
|
|
|
|
Can somebody tell me why this code is not working. It keeps saying
"A datasource instance has not has not been supplied for the data source.
Also I have scoured the web for some good documentation on how to set these up on the fly but I have not found any great info. Can somebody point me in the right direction?
private void toolStripButton1_Click_1(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
try
{
// Set Processing Mode
reportViewer1.ProcessingMode = ProcessingMode.Local;
// Set RDL file
reportViewer1.LocalReport.ReportPath = (Application.StartupPath + "\\reports\\trdReport.rdlc");
// Supply a DataTable corresponding to each report data source
reportViewer1.LocalReport.DataSources.Add(
new ReportDataSource("getTrends", LoadData()));
// Add the reportviewer to the form
reportViewer1.Dock = DockStyle.Fill;
// Process and render the report
reportViewer1.RefreshReport();
}
catch (Exception ex)
{
StreamWriter writer = new StreamWriter(logFile, true, System.Text.Encoding.ASCII);
writer.WriteLine(System.DateTime.Now);
writer.WriteLine("[generate report]");
writer.WriteLine("[generate report]");
writer.WriteLine(ex);
writer.WriteLine("\r");
writer.Close();
MessageBox.Show(ex.ToString());
//this.Close();
//System.Environment.Exit(0);
}
this.Cursor = Cursors.Default;
}
private DataTable LoadData()
{
// Load data from XML file
DataSet ds = new DataSet();
string myFilePath = (Application.StartupPath + "\\bin\\" + "trd.xml");
ds.ReadXml(myFilePath);
return ds.Tables[0];
}
tia
rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
It seems that the code works great. I deleted the report file and it worked.
reafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
i am developing c# desktop application. in that i want to connect to mysql database which is resides on another system.please give me an idea about this.
i have already replaced [
Data Source=MySQL Database;Server=localhost; user id=root;password=****;database=sample;pooling=true";] to
[Data Source=MySQL Database;Server=http://192.168.1.64; user id=root;password=gvsadmin;database=sample;pooling=true";]
is there any other way todo this?
thanks
|
|
|
|
|
You're changing the connection string to find the machine on the network. There's no other way to find it than this
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
This is the way I connect to a MySQL database:
string Connectstring = @"server=00.00.00.00;uid=YourUserID;pwd=YourPassword;database=YourDatabase;";
MySqlConnection ConnMySQL;
MySqlCommand cmdMySql = new MySqlCommand();
ConnMySQL = new MySqlConnection(ConnectString());
cmdMySql.Connection = ConnMySQL;
try
{
ConnMySQL.Open();
//Do your stuff
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show("Error:" + e.Message + Convert.ToChar(13) + e.GetType().ToString() + Convert.ToChar(13));
return null;
}
finally
{
ConnMySQL.Close();
}
I don't know if this is an answer to your question ?
My assumption is you adjusted SQL server code, but MySQL connection is different.
You also need to set a reference to the .Net connector component provided by MySQL.
Good luck,
|
|
|
|
|
Good people,
I have a quick question. For the screens in my application, before they load, I need to fetch data from the database, perform some calculations, then load it onto the screen. However, rather than the software just freeze up during this process, I would like the progress bar to indicate the, well, progress towards the screen being loaded.
My question is: how do I make the progress bar show the progress during that process of getting data from the database and updating the screen?
Thanks,
Blitz
|
|
|
|
|
|
You are correct!
Thanks,
Blitz
|
|
|
|
|
Hi all,
One of my windows application I want to read a text file and add the result into a list view.
What I've done is read the text file in a background thread. It's fine. But from the thread I cannot add data into the UI thread, basically to the list view. What can I do.
When I try to work on with the UI controls I got the following exception.
Cross-thread operation not valid: Control 'listView1' accessed from a thread other than the thread it was created on.
Can someone give me a comment on this.
If I don't use a background thread, while the text file read the UI is completely stuck and not responding.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
You need to use BeginInvoke[^]/Invoke for cross thread changes.
|
|
|
|
|
Thanks for the comment.
I've solved it using the avoiding the illegal thread calls of the form, with the background thread.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Hi all,
I have written an XML handler class for a project I am currently writing and all the read and write methods do what I expect of them.
It then occurred to me that the main code in this class should be able to do something along the lines of:
section("firstlevel")
{
section("secondlevel")
{
WriteValue("value1", 1);
WriteValue("value2", 2);
}
}
where "section" is a keyword of my XML class and the open and close curly brace calls XmlWriter.WriteStartElement() and XmlWriter.WriteEndElement() respectively creating section tags "firstlevel" and "secondlevel" as they do.
Google searches tend to turn up statements such as "use the keyword new" etc..
Just wondering on where to start on creating a keyword and if there is a suitable example I can follow to get started. Or if I can even do something like this at all.
Regards,
David Bailey.
|
|
|
|
|
You can't create a keyword, but of course you can create classes and methods. I'm wondering whether or not you are describing a recursive method to write out an XML document.
My preferred method of writing XML is by using an XmlDocument and calling its WriteTo method.
More detail would be required to help further.
|
|
|
|
|
Hi PIEBALDconsult,
Thanks for your reply.
No, I was not describing a recursive method. I was aiming for something that was easy to read and configure as well as being specific to a particular class.
What I was trying for was to override the curly braces, but apparently this is not allowed either. The curly braces would then have acted upon the new class keyword "section" to open and then close that section. The WriteValue("value1", 1) method would then place a value into the section.
using the above sample code, I would then get the output along the lines (minus the headers etc):
<firstlevel>
<secondlevel>
<value1>1</value1>
<value2>2</value2>
</secondlevel>
</firstlevel>
The "section" could be a method, granted, but then how do I complement it with curly braces such that
section("firstlevel")
{
}
could replace
openSection("firstlevel");
.
.
closeSection();
where openSection/closeSection are defined something like (just rough pseudo code)
XmlWriterSettings settings = new XmlWriterSettings();
XmlWriter writer = XmlWriter.Create(SettingsFile, settings);
private void openSection(string sect)
{
writer.WriteStartElement(sect);
}
private void closeSection()
{
writer.WriteEndElement();
}
I hope this makes sense. There is no great loss if I cannot achieve what I am aiming for. But it would be really good if it could be achieved.
Thanks again,
David.
|
|
|
|