|
Hi,
Pls let me know how to do the following in a Windows forms data grid (without using a database):
1]. I want one of the columns to be editable. Once the focus is lost after editing I want to check if the value is within the expected range. How to capture this lost focus event on a cell?
2]. I have 1 column of type bool (to have a checkbos). But while adding rows, for one of the rows I don’t want this check box to be seen. How to hide this based on row selection?
3]. I want to change the color of individual cells. How to do it?
4]. How to set the color of a particular row?
5]. How to merge two cells vertically in a data grid?
Thanks in advance
-- modified at 8:13 Wednesday 26th October, 2005
|
|
|
|
|
Hi,
Can someone tell me how to implement a VC++ toolbar like control in C#?
Requirements are as follows:
1. Tool bar should be vertical toolbar
2. It should be dockable within a selected panel
3. It should have buttons and on dragging and dropping of these buttons, a control (e.g. combobox) should get created on the panel.
Thanks in advance.
ckravi
|
|
|
|
|
Hi,
ComponentOne has a Menus and Toolbars for .NET control that meets your needs. It includes a standard toolbar, a main menu, tab, and an "Out Bar"; all of which can be docked. For more information, please see our website, http://www.componentone.com[^].
Suelinda W
Customer Engagement, ComponentOne LLC
|
|
|
|
|
Hello Friends;
I program a software under .net using c#. i try to make comminicate and use RFID kit.(its model is MR100A reader and ANT34-24 antenna)
If you send me .net DLL or .net component for read,write,connect etc. operation i will be so happy. Thanks you
This is Your Life And Its ending one minute at a time
|
|
|
|
|
Generic components like that don't exist. Your best place for an SDK, or some other developement tools and documentation, for this device would be the manufacturer.
For instance, I could send you the SDK's I have for my RFID devices (I can't really because they cost a BUNCH of money!), but I garantee you they won't work with your device. One is a handheld RFID ID gun that runs on a serial port and the other is a pole-mounted RFID ID system that communicates on Ethernet. The two do the same job, but are completely incapable of communication using the same methods.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello
Thanks for your reply. I found only sdk but can you show me the way how can i insert it to my program or directly use it. i need exactly .net component but they sell it over 2.000 $ this is bullshit? i need your helps. Thanks
This is Your Life And Its ending one minute at a time
|
|
|
|
|
How many thread is alowed in app? I have found out that 25 is ok. I am using 6 and the system is using up 100% of processor. All the threads are suspended. I have debugged the app and there is no threads runnng. But when the last thread is suspended, the processor go up to 100%. I thougt that the last thread didn't sysspend, but i did. Iven if I remove the suspend command for the thread and just let it run one empty function. The processor is boosted to 100%
|
|
|
|
|
hg2705 wrote: How many thread is alowed in app?
I don't know of any fixed limits, but in general, anything above 10 and performance starts to go down. Most of the time will be taken by context switches rather than any useful work.
hg2705 wrote: Iven if I remove the suspend command for the thread and just let it run one empty function. The processor is boosted to 100%
Maybe some other process is running that's taking up the CPU? You can easily check that using TaskManager.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thing is that i create a smal app that starts 10 threads, start them and suspend them at once. The processor is bosted to 100%. The maschine im using is an campaq notebook 600mz. 10 threds thar are suspended should not bee so har do handle...
<br />
public app()<br />
{<br />
mRun = true;<br />
mThreads = new ArrayList();<br />
for(int i = 0; i<10; i++)<br />
{<br />
Thread t = new Thread(new ThreadStart(this.go));<br />
t.Name = i.ToString();<br />
t.Start();<br />
t.Suspend();<br />
mThreads.Add(t);<br />
}<br />
}<br />
private void go()<br />
{<br />
while(mRun)<br />
{<br />
listBox1.Items.Add("run");<br />
Thread.Sleep(10000);<br />
}<br />
}<br />
-- modified at 2:14 Friday 28th October, 2005
|
|
|
|
|
Like I said, did you check if some other process is taking up processor time?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I've created a class containing a method to make a connection with a database and do SELECT, INSERT, UPDATE, DELETE. The class works just fine... only for the first query. The problem occurs when the second query is made. The result of the second query is just fine but at VERY VERY slow rate (almost not responding). Here's my class:
class MyClass
{
public string SQL2KConnStr = "..(my connection string)..";
public object ExecuteSql(string sql)
{
SqlConnection conn = new SqlConnection(this.SQLExpressConnStr);
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
conn.Open();
switch(sql.Trim().Substring(0,6).ToLower()){
case "select":
SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
adapter.Fill(ds, "QueriedTab");
return ds.Tables["QueriedTab"];
break;
default:
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = sql;
return cmd.ExecuteNonQuery();
}
}
And this's another class that makes use of the class above:
string SqlSelect = "select * from ...";
MyClass mc = new MyClass();
DataTable tab = (DataTable)mc.ExecuteSql(SqlSelect);
myDataGrid.DataSource = tab;
tab.Dispose();
I display the resultin a datagrid. The correctness of the result is fine. But the speed of the second and after is SO SO slow even though i've disposed the returned table every time. Anybody help me please...
KiT
|
|
|
|
|
KiTsuNeKo wrote: if (conn.State == ConnectionState.Open) { conn.Close(); }
Rather close the connection after your query.
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
You are creating a new connection object each call to the function, and you're not closing it when done (garbage collection will eventually do so, but this is not good practice.
try this:
public class MyClass
{
private SqlConnection conn = new SqlConnection(this.SQLExpressConnStr);
public string SQL2KConnStr = "..(my connection string)..";
public object ExecuteSql(string sql)
{
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
switch(sql.Trim().Substring(0,6).ToLower())
{
case "select":
try
{
SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
ds = new DataSet();
adapter.Fill(ds, "QueriedTab");
}
finally
{
conn.Close();
}
return ds.Tables["QueriedTab"];
break;
default:
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = sql;
long rtn = 0;
try
{
rtn = cmd.ExecuteNonQuery();
}
finally
{
conn.Close();
}
return rtn;
break;
}
}
}
Only create the connection once, open and close it with each use.
You might want to add catch(SqlException e)
blocks before each finally block to handle errors.
probably want to move the declaration of the dataset to class or function scope (out of the try block)
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
I've tried the solution but the problem still exists... T-T There're only 130 records in the database and it shouldn't take so long to query them all.
KiT
|
|
|
|
|
Dear Experts,
I installed my own created Windows Service by using the command "installUtil". Now I would like to un-install that service but I don't know how to do so. Could you please advise?
Many thanks.
Tigger
|
|
|
|
|
you need to pass an extra parameter to installutill
That might be -u
- ashish
|
|
|
|
|
i've been researching for a technique on how to create an excel-compatible dbf file. so far, i've downloaded a sample program in http://www.c-sharpcorner.com/Code/2002/Feb/xBaseEngineRFV.asp.
the output file is good and can be opened in visual foxpro 9, but my problem is my client wants to open it in excel. he's used to opening dbf's in excel.
can somebody help me please?
i'm not always on here, so please email your answer to xmione@yahoo.com
tnx
Solomio S. Sisante
c# Senior Developer
|
|
|
|
|
In MFC you can assign a pointer or other 4 byte value to each item in a list control via GetItemData / SetItemData. Is there an equivilent in dot net?
|
|
|
|
|
I think I figured it out. You add your actual object to the list control and then override the ToString() on that object rather than Items.Add(object.ToString());
pretty cool
|
|
|
|
|
or you can go one better and create your own listitem object that inherits listitem and add your own public propeties
like this
public class MyListItem : ListViewItem
{
public string myvalue;
}
then use MyListItem class when creating ListviewItems and you'll have access to myvalue!
C# is very cool
-= Technomancer =-
|
|
|
|
|
Thank you.
Can you do in place editing of List Box Items?
|
|
|
|
|
Hi!!
I have a call to my data access class and I do it like this (from my displayNews.aspx page:
News objNews = NewsDA.GetNewsDetails(m_iNewsID);
m_iNewsID is the id number which I got from the query string
And my GetNewsDetails in my NewsDA class looks like this:
public static News GetNewsDetails(int intNewsID)
{
News objNews = new News();
// Create instance of connection and command object
SqlConnection objConn = new SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);
SqlCommand objCmd = new SqlCommand("sp_GetNewsByID", objConn);
// Mark the command as a SPROC
objCmd.CommandType = CommandType.StoredProcedure;
// Add parameters to SPROC
SqlParameter paramNewsID = new SqlParameter("@NewsID", SqlDbType.Int, 4);
paramNewsID.Value = intNewsID;
objCmd.Parameters.Add(paramNewsID);
// Execute the statement
try
{
objConn.Open();
SqlDataReader objDr = objCmd.ExecuteReader();
try
{
while (objDr.Read())
{
objNews.NewsID = Convert.ToInt32(objDr["PKNewsID"]);
objNews.CategoryID = Globals.CheckDBIntForDBNulls(objDr["FKNewsCategoryID"]);
objNews.Title = objDr["NewsTitle"].ToString();
}
}
finally
{
if(!objDr.IsClosed)
{
objDr.Close();
}
}
}
finally
{
if(objConn.State == ConnectionState.Open)
{
objConn.Close();
}
objConn.Dispose();
objCmd.Dispose();
}
// Return the news object
return objNews;
}
If no records are found, then I should probably set objNews to null?? And the where I call this function, then I should probably test if the news object is equal to null?? I was thinking of putting in an if statement there in the second try block, if the dataset has rows, then do the while statement, otherwise set the objNews = null??
Please can some one advise. If there is a better way of testing if an object of News has any records (rows) in it, please let me know.
Regards,
ma se
|
|
|
|
|
Use a DataAdapter to fill a Datatable/Dataset .
xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
|
|
|
|
|
Yes, but I am not returning a lot of records, just one based on the ID, so won't the data reader be the best way?
If I were to use the data reader, where and how would I test if any records were found?
|
|
|
|
|
If you are going to put the data into your business object (News ) then I do not suggest using a SqlDataAdapter to fill a DataTable /DataSet because all you are going is wasting time creating extra copies of the data that you will throw away. (The SqlDataAdapter uses a SqlDataReader internally to populate the DataTable /DataSet )
You could look at the SqlDataReader.HasRows[^] property.
At the top of your method replace
News objNews = new News(); with
News objNews = null; . Wait until you perform the ExecuteReader() then, inside your try block (replacing the while loop), do something like this:
if (objDr.HasRows)
{
objNews = new News();
objDr.Read()
objNews.NewsID = Convert.ToInt32(objDr["PKNewsID"]);
objNews.CategoryID = Globals.CheckDBIntForDBNulls(objDr["FKNewsCategoryID"]);
objNews.Title = objDr["NewsTitle"].ToString();
} I took out the while because it wasn't really doing anything useful. If you expect only one row to be returned then the above will be fine. If you expect more than one row returned and you are just looking for the results of the last row then your old while loop will work, but it suggests there is something wrong with the SQL that it is returning more than it should.
Now, if no rows are returned from SQL Server, a null is returned from the method.
Does this help?
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|