|
what's connection string for sdf file ?
|
|
|
|
|
|
I used this connectionString
"Data Source=|DataDirectory|TMCDataBase.sdf;Persist Security Info=False"
Error : An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
|
|
|
|
|
How did you initialize the connection?
I think you have used this:
conn = new SqlConnection("Data Source=|DataDirectory|TMCDataBase.sd;Persist Security Info=False");
But the correct way is:
conn = new SqlCeConnection("Data Source=|DataDirectory|TMCDataBase.sd;Persist Security Info=False");
In order to use SqlCeConnection class, you should reference System.Data.SqlCe.dll.
|
|
|
|
|
I am looking for a way to subscribe to system events so when a new system event is added to the system event log, I can be notified and grab information about the event. So far I have found a way to grab system events, however I do not know how to use this to be notified when a new event has been logged. I also found a way to listen for system events, but this
way is limited to certain events and does not provide the information on the event that I need. Any suggestions on either a new way to get what I need or how to use what I already found? Thanks.
|
|
|
|
|
Solved, used EntryWrittenEventHandler in System.Diagnostics.EventLog
|
|
|
|
|
I need datagridview component that I can show picture and
Information of peopel in it (Like XamDataGrid)
please help me
|
|
|
|
|
How about DataGridViewImageColumn? Are you looking for something more than that?
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
datagrid like XamDataGrid but XamDataGrid is wpf I need component for win application
|
|
|
|
|
I don't know what WPF grid looks like so can't help.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
I have a very simple DataGridView:
public Form1()
{
InitializeComponent();
DataGridView dataGridView1 = new DataGridView();
DataTable dataTable = new DataTable();
dataGridView1.DataSource = new BindingSource(dataTable, null);
dataTable.Columns.Add("My Column");
dataTable.Rows.Add("My Cell Value");
Console.WriteLine("There are " + dataGridView1.Rows.Count + " rows in your table.");
this.Controls.Add(dataGridView1);
}
The table is displayed correctly with one row, but the print out says there are zero rows in the table. Why is that? And if I want to obtain other information about rows and cells (such as their locations), how do I do that? I would prefer to keep my DataGridView bound because I find the filter functionality to be very useful.
|
|
|
|
|
arnold_w wrote: but the print out says there are zero rows in the table. Why is that?
There has to be some problem with your printing code. Try debug that or post it here.
arnold_w wrote: I want to obtain other information about rows and cells (such as their locations), how do I do that?
Try using GetCellDisplayRectangle method.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
d@nish wrote: arnold_w wrote:
but the print out says there are zero rows in the table. Why is that?
There has to be some problem with your printing code. Try debug that or post it here.
The code is posted here and the printing code is the second row from the end.
d@nish wrote: arnold_w wrote:
I want to obtain other information about rows and cells (such as their locations), how do I do that?
Try using GetCellDisplayRectangle method.
If I add the following code at the very end:
try
{
Rectangle cellRectangle = dataGridView1.GetCellDisplayRectangle(0, 0, true);
Console.WriteLine("The cell is located at " + cellRectangle.X + ", " + cellRectangle.Y + ".");
}
catch (ArgumentOutOfRangeException e)
{
Console.WriteLine("ArgumentOutOfRangeException. Additional info: " + e.Message);
}
I get an ArgumentOutOfRangeException saying the parameter is outside the valid range. What I missing here?
|
|
|
|
|
arnold_w wrote: The code is posted here and the printing code is the second row from the end
Sorry. I thought you are speaking of printing (hard copy) datagridview. I took a look at your code. Here are some comments:
1. Get rid of binding source and use this:
DataGridView dataGridView2 = new DataGridView();
DataTable dataTable = new DataTable();
dataTable.Columns.Add("My Column");
dataTable.Rows.Add("My Cell Value");
dataGridView2.DataSource = dataTable;
2. What I found from debugging is that unless form is loaded, you don't get the row count. Not sure of reason* but you do get the count in load. So probably if you check for row count in the load event, you would get the correct result.
The second exception is also for the same reason. Put that as well in the Load event and I guess it should work.
*I have posted a question regarding same. You can check that and get to know the reason.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Ok, so I should do something like this instead:
public Form1()
{
InitializeComponent();
this.Load += new EventHandler(Form1_Load);
}
private void Form1_Load(object sender, System.EventArgs e)
{
DataGridView dataGridView1 = new DataGridView();
DataTable dataTable = new DataTable();
dataTable.Columns.Add("My Column");
dataTable.Rows.Add("My Cell Value");
dataGridView1.DataSource = dataTable;
this.Controls.Add(dataGridView1);
Console.WriteLine("There are " + dataGridView1.Rows.Count + " rows in your table.");
}
?
It does seem to work properly.
|
|
|
|
|
d@nish wrote: 1. Get rid of binding source and use this:
DataGridView dataGridView2 = new DataGridView();
DataTable dataTable = new DataTable();
dataTable.Columns.Add("My Column");
dataTable.Rows.Add("My Cell Value");
dataGridView2.DataSource = dataTable;
Ooops, I just discovered that if I don't use BindingSource, I can't use the BindingSource.Filter method. The reason I want a bound form is that I need filter-functionality. Is there a workaround for this?
|
|
|
|
|
There is a RowFilter property (don't remember if it is of datatable.defaultview or of the datagridview). You can use that.
For your other post, check first if the designer file has the code to attach the event handler (+= thing). It depends on the way you create the event.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
The following works great:
DataView dv = dataTable.DefaultView;
dv.RowFilter = ...
Thanks a lot for your help!
|
|
|
|
|
What is the differentiation between Singleton Class and Static Class ?
Thanks...
|
|
|
|
|
A singleton object can be used as a parameter to a method, but a static class can't.
Also, I don't think you can inherit an interface with a static class.
BTW, if you had used google, you could have found this answer a lot faster.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
A singleton can be used in places where you need an instance, so you can still do all that inheritance/polymorphism/etc with it
A static classes can only derive from Object and can not implement interfaces
|
|
|
|
|
All members inside a static class would be static - and hence not available for automatic garbage collection until the app domain is unloaded.
In the case of a singleton class, the instance variables defined in the class will be available for garbage collection.
So singletons have an advantage with respect to memory de-allocation.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
Hi, I think the difference between the two classes is that
Static Class needs no instance of the object,
while Singleton needs one instance of object and to keep the state.
modified 27-May-14 4:59am.
|
|
|
|
|
Hey how to generate orthogonal partitions. I have a rectangle and i wish to divide it into 8 random partitions and load an image into each partition. can anyone tel me how to do it?
|
|
|
|
|
Hi,
maybe like so:
0. create one random number generator; use only one!
1. choose a random number in the range [0, 2) to select direction (0=horizontal, 1=vertical).
2. choose a random number in the range [0, max) where max is either width or height.
3. repeat 1+2 three times.
You now have 8 rectangles inside the original one.
refinements: impose a minimum width and height for each of them by limiting the range in (2) somewhat.
|
|
|
|