|
hi all
I Wount to add DataGrid To my Mobil Application With this propertis
1- columns type combobox
2- columns type CheckBox
3- Columns type Buttun To delete the row selected by click to this button in grid this button is in evry row
thanks All
Thaer (T.h)
Thaer
|
|
|
|
|
When running the code below on a win 2003 server i receive all the 4 columns in the csv file, when doing it on xp I only get one column !?!?! how weird is that on a scale !? ...somebody run into this ?
string strImportPath = "C:\\inetpub\\wwwroot\\TempUpload\\";
string strConn = "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + strImportPath.Trim() + ";Extensions=csv,txt;Persist Security Info=False";
OdbcConnection myConnection = new OdbcConnection(strConn);
myConnection.Open();
OdbcDataAdapter myAdapter = new OdbcDataAdapter("select * FROM Manufacturers.txt", myConnection);
DataSet ds = new DataSet();
try
{
myAdapter.Fill(ds,"fungus");
}
catch(Exception ex)
{
string messages = ex.Message.ToString();
}
dataGrid1.DataSource = ds.DefaultViewManager;
dataGrid1.DataMember="fungus";
myConnection.Close();
peirre
|
|
|
|
|
Haven't worked with MS Text Driver or any csv data but first thing that comes to mind is:
Make sure Regional settings are compatible with your .txt files. Maybe your list separator is not the same in both OS.
|
|
|
|
|
hi...
I am using the following code:
OurApp.LIB.TestData TestD = new OurApp.LIB.TestData();<br />
TestD.LoadData(2,Convert.ToString(lvTestA.SelectedItems[0].SubItems[0].Text.Trim()));
now this is all in the:
private void lvTestA_SelectedIndexChanged(object sender, EventArgs e)<br />
{<br />
If you click on a item in the listview (the first time) it works fine.
Once you click on another item in the listview it comes up with the error...
"InvalidArgument = Value of '0' is not valid for 'index'. Parameter name: index"
why could this be?
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
never mind.... i just put in a if(lvTestA.selecteditems.count > 0)
{
and now it works fine...
It seems that the item isnt really selected as soon as you click it... (it is cleared and then selected ???)
Thank you anyway
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Hi,
I guess there are two changed events, one when the original selection gets unselected,
the second one when the newly clicked item gets selected.
BTW do all items have subitems ?
|
|
|
|
|
yes all items have subitems
Thanks...
i thought that there are two events taking place in the SelectedIndexChange event just after i posted the message...
Thank you for your time
"Many of life's failures are people who did not realize how close they were to success when they gave up." Thomas A. Edison
|
|
|
|
|
Support123 wrote: Convert.ToString(lvTestA.SelectedItems[0].SubItems[0].Text.Trim())
See all that - I'd separate that out into lots of lines as it makes it much easier to debug. This is the only code that appears to use indexes so I'm guessing it is here that the problem lies.
selectedItems = lvTestA.SelectedItems;
firstItem = selectedItems[0];
subItems = firstItem.SubItems;
firstSubItem = subItems[0];
string theText = firstSubItem.Text;
string theTrimmedText = theText.Trim();
string convertedText = Convert.ToString(theTrimmedText);
TestD.LoadData(2,convertedText);
NOTE: I've left out the class names for most of the above - you'll have to fill that in.
The above code can now be much more easily debugged and stepped through. You can then see exactly which line has the problem - And you can watch the values so you can see exactly what it is doing.
This should help you narrow down your problem.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Hi,
I guess there are two changed events, one when the original selection gets unselected,
the second one when the newly clicked item gets selected.
Thaer
|
|
|
|
|
Please, tell me that Luc and you are twins and you allways think the same.
Otherwise it would look like you copied Luc's suggestion![^]
Hmm, just compared you two Birthday dates and I have to say it's a big gap in between.
Sorry Luc, don't want to say that you are soo old!
All the best,
Martin
|
|
|
|
|
Then why did you ?
|
|
|
|
|
Hmmmm,
I just wanted to show the community how well experienced you are!
All the best,
Martin
|
|
|
|
|
I m trying to make an application which is connected with more than one database and its depend on user that user may have any name so I create a database name is blank in bin --> debug folder when user make a new colony database. It copy from the existing database which have already same tables query etc.
plz give me coding.
plz help me and thakx in advance
Nikesh Yadav,
CSS infotech,
Gurgaon,
Haryana(India).
|
|
|
|
|
Er nikesh yadav wrote: plz give me coding
The code will be highly dependent on the database that you use.
If it is Access then a simple file copy might suffice
If it is SQL Server the two choices I'd look at would be to restore a blank database to the location that you want, or to have a set of scripts to create a brand new database
Other database system may offer similar choices, they may offer something completely different.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
|
Then you probably just want to copy the file. See the FileInfo class.
See: MSDN - FileInfo[^]
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Hello All,
I am trying to bind the listbox to a column of the datatable. If i try directly on the click of the button then it will display the data. but, if i am trying to do this by creating a thread for this process it is doing nothing, no error is shown. Please help me.
Thanks in advance.
Bharath.S Ron
|
|
|
|
|
I think an exception IS thrown however you catch it on some place. You cannot change GUI related things on a diffrent thread.
Try creating a delegate and call the delegate from your diffrent thread using Invoke()
for example :
<br />
private delegate void doBindListbox();<br />
private void BindListbox()<br />
{<br />
}<br />
and call the delegate from your diffrent thread like so :
<br />
this.Invoke(new doBindListbox(BindListbox));<br />
|
|
|
|
|
Hi,
Is this the correct way?
trd = new Thread(new ThreadStart(this.Invoke(new delegateloaddata(loaddata))));
delegateloaddata = delegate.
loaddata = is the method which has to be called through thread
Bharath.S Ron
|
|
|
|
|
No, it's not...
<br />
private void StartMyThread()<br />
{<br />
ThreadStart ts = new ThreadStart(InvokeBinding);<br />
Thread th = new Thread(ts);<br />
th.Start();<br />
}<br />
<br />
private void InvokeBinding()<br />
{<br />
this.Invoke(new doBindListbox(BindListbox));<br />
}<br />
See the example in my previous post....
|
|
|
|
|
Thank you.
I tried that method it is working and loading the data into the listbox but, it is not working as a thread. I cannot stop it in between.
Bharath.S Ron
|
|
|
|
|
What do you mean with :
Bharath.S.Ron wrote: I cannot stop it in between.
|
|
|
|
|
Hi,
AS i am trying to impliment that as a thread , i want to stop it in between as well.
stop in the sense, the form should not freeze while performing that function, i should be able to click other buttons as well while this is being doing its job.
Bharath.S Ron
|
|
|
|
|
this is the code which i am using.
public void loaddata()
{
try
{
conn = new SqlConnection("Data Source=local; Initial Catalog=Northwind; User ID=sa; Password=; Persist Security Info =True;");
adpt = new SqlDataAdapter("Select * from Categories", conn);
ds = new DataSet();
adpt.Fill(ds);
listBox1.DataSource = ds.Tables[0];
//trd
listBox1.DisplayMember = "CategoryName";
Thread.Sleep(1000);
//trd.Start();
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
on click of the button i am calling that thread.
private void btnStart_Click(object sender, EventArgs e)
{
try
{
// this is wokring
ThreadStart myThreadDelegate = new ThreadStart(loaddata);
trd = new Thread(myThreadDelegate);
trd.Start();
trd.IsBackground = true;
// till here
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
this below code is to stop the thread.
private void btnStop_Click(object sender, EventArgs e)
{
//Thread trd = new Thread(new ThreadStart(this.loaddata));
//trd.Abort();
try
{
if ((trd.ThreadState == ThreadState.Running )|| (trd.ThreadState==ThreadState.Background))
{
trd.Abort();
}
}
catch (ThreadStateException Ex)
{
MessageBox.Show(Ex.ToString(), "Exception",
MessageBoxButtons.OK, MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1);
}
}
please help me..
Bharath.S Ron
|
|
|
|
|
Hi,
I Have Some Problem how can we bind data into tab control..for example:
i have a table name Working, in first column i have field name "Id" for primary key and i make it autoincrement, and in the second column i have field name Status..what makes me confuse if on field status have 2 value :"typing, printing"..how can i make tab control have 2 tabPages name "typing" and "printing"
Please Help me coz i'm new in C#...
Thanks and Regard,
TCim
|
|
|
|