|
_AKA_KSN_ wrote: But we found a different cause for this problem, in my DataGrid we have enabled Virtualization Virtual Mode does not slow down the grid; on the contrary, it's used when databinding is too slow.
_AKA_KSN_ wrote: which mean the Ui takes long time The UI-thread is there to paint a UI, not to load data or do conversions.
_AKA_KSN_ wrote: have to do some enough study in enabling virtualization. There's a walkthrough here[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
It sounds to me like you are solving the wrong problem here. Rather than attempting to do business calculations in converters, you should create a ViewModel and perform your calculations in there. One of the overheads you have in a converter is that all elements are treated as objects, so you have unboxing to cope with.
|
|
|
|
|
hi, I use below code to create/consume and dispose sql connections.But as there are more than twenty methods/functions that I use it, same code block repeats. So, is it goog practice? Your valuable comments are welcomed.
private void islemKayitlariniYukle(string select)
{
using (SqlCeConnection sqlCEBaglantisi = new SqlCeConnection(Properties.Settings.Default.sqlBag))
using (SqlCeDataAdapter sqlAdaptor = new SqlCeDataAdapter(select, sqlCEBaglantisi))
using (DataTable dtTablo = new DataTable())
{
sqlCEBaglantisi.Open();
sqlAdaptor.Fill(dtTablo);
SqlCeCommand islemTipleriniAl = new SqlCeCommand("Select IslemTipi From IslemKaydi Group By IslemTipi", sqlCEBaglantisi);
using (SqlCeDataReader oku1 = islemTipleriniAl.ExecuteReader())
{
while (oku1.Read())
{ cmbIGIslemTipiSec.Items.Add(oku1.GetString(0).Trim()); }
}
|
|
|
|
|
teknolog123 wrote: same code block repeats. You could wrap some things in their own method
teknolog123 wrote: So, is it goog practice? Not if you're religious about the DRY-principle. In that case, there'd be a factory to return an IDbConnection , and the query-string would be passed to a method containing the database-connection logic.
Still, with or without the repeating code; I could work with it. If you'd use English names for your variables, I might even be able to understand it's intention
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
thanks let me explain more. I just want to dispose sqceConnection, sqlceCommand, SqlCeCommandBuilder and sqlceAdapter as soon as I finish processing the data. for example does the below code dispose the objects in that manner? I think no but wanna make sure. (note: I didn't use sqladapter and commnadbuilder below to keep the code short on purpose)
public SqlCeConnection sqlSetCon()
{
SqlCeConnection sqlCon = new SqlCeConnection();
sqlCon.ConnectionString = Properties.Settings.Default.sqlConnStr;
sqlCon.Open();
return sqlCon;
}
public DataTable returnDataTable(string selectString)
{
SqlCeDataAdapter sqlAdaptor = new SqlCeDataAdapter(selectString, sqlSetCon());
SqlCeCommandBuilder sqlKomut = new SqlCeCommandBuilder(sqlAdaptor);
DataTable dtTablo = new DataTable();
sqlAdaptor.Fill(dtTablo);
return dtTablo;
}
private void processList()
{
using (DataTable dt = returnDataTable("Select * From Customers Order By Surname"))
{
for (int i = 0; i < dt.Rows.Count; i++)
{
this.lblSurname.Text = dt.Rows[i]["surname"].ToString();
}
}
}
modified 2-Feb-14 6:38am.
|
|
|
|
|
Something similar to below; wrap the disposable's in a using-section, and they'll be disposed when they go out of scope.
public DataTable returnDataTable(string selectString)
{
using (var con = sqlSetCon())
using (SqlCeDataAdapter sqlAdaptor = new SqlCeDataAdapter(selectString, con))
{
DataTable dtTablo = new DataTable();
sqlAdaptor.Fill(dtTablo);
return dtTablo;
}
}
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
thanks Eddy, by the way, is it only those that are written in parentheses disposed or anything in curly braces?
|
|
|
|
|
teknolog123 wrote:
thanks Eddy, by the way, is it only those that
are written in parentheses disposed or anything in curly braces?
Anything that's disposable would be best in a using -clause. You can try it by putting it in a using, if it's not disposable you'll get a compiler-error saying so. Alternatively, you can check MSDN.
If you can't limit it to a scope, then you'd best dispose it from code later.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
how to use Switch Startup Project extension in visual studio 2012
|
|
|
|
|
You mean other than download it[^], install it, and follow the instructions on the page you got it from?
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Actually ive downloaded from that site only , but i.e for VS2010,
do u have any idea that is there any extension for VS2012
|
|
|
|
|
The site doesn't list any different download, but does list 2012 and 0213 in the compatibility list.
So have you enabled it? Displayed the toolbar / toolbar item?
If so, then you probably need to talk to the author: there is a Q&A tab on the page.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
What problem are you having installing, or using, it ? [^].
“But I don't want to go among mad people,” Alice remarked.
“Oh, you can't help that,” said the Cat: “we're all mad here. I'm mad. You're mad.”
“How do you know I'm mad?” said Alice.
“You must be," said the Cat, or you wouldn't have come here.” Lewis Carroll
|
|
|
|
|
problem in using ,
i installed but i.e is not appearing on Visual Studio
NOTE:I am using Visual studio 2012,
i didnt find any where that Extension for 2012
|
|
|
|
|
Hi Dear Friends;
Want to ask a question about SqlDependency.
C # sql operation with SqlDependency in my side I want to see.
Example:
I got 2 MSSQL database,
are the first data in my database.
When you take action in the first database, Current Data I want to add my second database.
SqlDependency with the insert, update, delete, how do you find out the line?
I use the sample code I'm writing.
When you take action on this sql code can trigger windows form.
I'm asking transactions which took place in line?
I'm sorry for bad english.
#region Using directives
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.Data.SqlClient;
#endregion
namespace NotifySample
{
partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SqlConnection con;
SqlCommand cmd;
SqlDependency dep;
SqlDataAdapter da;
DataTable dt;
private void btnVeriCek_Click(object sender, EventArgs e)
{
con = new SqlConnection("data source=localhost;initial catalog=Dukkan;integrated security=SSPI");
con.Open();
cmd = new SqlCommand("Select DetayID,PersonelID,Ad,Soyad,Mail From dbo.PersonelDetay", con);
dep = new SqlDependency(cmd);
SqlDependency.Start("data source=localhost;initial catalog=Dukkan;integrated security=SSPI");
dep.OnChange+=new OnChangeEventHandler(dep_OnChange);
da = new SqlDataAdapter(cmd);
dt = new DataTable();
da.Fill(dt);
dgVeriler.DataSource = dt;
}
void dep_OnChange(object sender, SqlNotificationEventArgs e)
{
MessageBox.Show("THIS AREA SQL INSERT, UPDATE, DELETED WANT TO SEE DATA");
}
}
}
|
|
|
|
|
byerkan wrote: When you take action in the first database, Current Data I want to add my second database. Sounds like replication/synchronization to me.
byerkan wrote: SqlDependency with the insert, update, delete, how do you find out the line? You can't.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
save dynamically created chart in Extjs to perticular location , and after that getting image to specified loaction for exporting pdf document
Raju88
|
|
|
|
|
Is that a question or a statement? And given that Extjs is a Javascript product, what has this to do with C#?
Veni, vidi, abiit domum
|
|
|
|
|
Tic Tac Toe
code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Tic Tac Toe
{
public partial class Form1 : Form
{
private GameManager game_manager = new GameManager();
public Form1()
{
InitializeComponent();
}
private void Clicked(object sender, EventArgs e)
{
Button button = (Button)sender;
switch (button.Name)
{
case "button1":
game_manager.ButtonClicked(0, button, label1);
break;
case "button2":
game_manager.ButtonClicked(1, button, label1);
break;
case "button3":
game_manager.ButtonClicked(2, button, label1);
break;
case "button4":
game_manager.ButtonClicked(3, button, label1);
break;
case "button5":
game_manager.ButtonClicked(4, button, label1);
break;
case "button6":
game_manager.ButtonClicked(5, button, label1);
break;
case "button7":
game_manager.ButtonClicked(6, button, label1);
break;
case "button8":
game_manager.ButtonClicked(7, button, label1);
break;
case "button9":
game_manager.ButtonClicked(8, button, label1);
break;
}
}
private void label1_Click(object sender, EventArgs e)
{
label1.Text = "";
label2.Text = "";
}
private void resetButton_Click(object sender, EventArgs e)
{
button1.Text = "";
button2.Text = "";
button3.Text = "";
button4.Text = "";
button5.Text = "";
button6.Text = "";
button7.Text = "";
button8.Text = "";
button9.Text = "";
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
|
|
|
|
|
Write a better game manager that maintains state better that you are now??
|
|
|
|
|
just check in the switch statement that if the control already has some value then do nothing.
|
|
|
|
|
I didn't downvote, but just have to ask - you don't really want to encourage adding an if to each case. Not if there's an option to use GOTO .
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
oh sorry, i knew that it has to be re-written but if he wishes to continue with it he can add the code above. re-writting code recommended
|
|
|
|
|
Hi, I have a syntax question on extension method syntax.
Here is my most simple extension method code
using System;
using ConsoleApplication1;
namespace extensionTestNamespace.test.com
{
public static class ExtensionTest
{
public static String AAAAAAA<T>(this T x) where T : TestClass1
{
return "Extension Method Test";
}
}
}
and here is the code that uses it
using System;
using extensionTestNamespace.test.com;
namespace ConsoleApplication1
{
public class TestClass1 { }
public class TestClass2 { }
public class TestClass3 { }
class Program
{
private void run()
{
TestClass1 test1 = new TestClass1();
TestClass2 test2 = new TestClass2();
TestClass3 test3 = new TestClass3();
Console.WriteLine(test1.AAAAAAA());
Console.WriteLine(test2.AAAAAAA());
Console.WriteLine(test3.AAAAAAA());
}
static void Main(string[] args)
{
Program program = new Program();
program.run();
}
}
}
My question is the syntax to allow the extension method AAAAAAA to test1 and test2 but not to test3. I had wanted to write this code
public static String AAAAAAA<T>(this T x)
where T : TestClass1
where T : TestClass2
but it won't compile.
What I do not want to do is add a special extension method for each class type. What I do want is a single extension class but the where clause constraint has TestClass1 and TestClass2 but not TestClass3.
I don't know how to do it. Can it be done and if so I would appreciate help on the C# syntax.
Thank you
|
|
|
|
|
You can't do that. There's simply no way to express it. You could do it if TestClass1 and TestClass2 both extend some base class or implement some interface that TestClass3 does not, but you can't express a restriction "must be subtype of TypeA or of TypeB".
Here's what the standard[^] has to say about where:
We can supply an optional list of constraints for each type parameter. A constraint indicates a requirement
that a type shall fulfill in order to be accepted as a type argument. (For example, it might have to implement
a given interface or be derived from a given base class.) A constraint is declared using the word where,
followed by a type parameter and colon (: ), followed by a comma-separated list of constraints, which can
include a class type, interface types, other type parameters, the reference type constraint “class”, the value
type constraint “struct”, and the constructor constraint “new()”
The only thing that can do is express one or several constraints that must all be fulfilled.
|
|
|
|
|