
fguihen
Avatar/Signature-
Posts
251 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by fguihen
-
im adding text to a richTextBox through code. like so: myRichTextBoxEx.SelectedText = "The following is a list of fintans test:"+ "\n" ; i want to be able to set tabs for my text but i cant get it done. heres what ive tried: int[] tabs = {100,300,600,900}; this.myRichTextBoxEx.AcceptsTab = true; this.myRichTextBoxEx.SelectionTabs = tabs; myRichTextBoxEx.SelectionStart = tabs[0]; myRichTextBoxEx.SelectedText = "The following is a list of fintans test:"+ "\n" ; it has absolutely no effect on the position of my text in the text box. actually, when i try to assign tabs[0] to SelectionStart, SelectionStart is always left at 0,no matter how i try to assign a value to it. what am i doing wrong?
-
i want to programatically add my own tab stops to a rich text box. i have been trying this for a while and cant get it done, and i cant seem to find any examples on the web. i want simply to be able to add text, through code so that it starts at a specific tab
-
i have an object that talks to the database and returns a dataset. i use this object more than once in my form, but each time i use it, the contents of any datasets that obtained data from it before are changed. i noticed it when a datagrid bound to a dataset kept changing as i used this object. how do i pass datasets by value rather than by ref
-
i have a habbit of writing code as i go along, and tackling problems as i meet them, but my code is a bit of a mess because of this, and difficult to read when you come back to it after a few weeks. does it make much of a diference to plan out your coding strategy first? the thing is that im not awfully expirienced, and to plan something , you need to know how it all works first and i learn as i go along. how do you all keep your code tidier?
-
i have databound a combo box to a column in a table like so: this.comboBox7.DataSource = ds.Tables["treatment_main"]; this.comboBox7.DisplayMember = "main_cat"; when the value of comboBox7 is changed i want to populate a second combo box. when i try to grab the value of the combobox7 i cant. i have placed this code in both the SelectionChangeCommitted and the SelectionChanged methods, like so: ComboBox cb = (ComboBox) sender; string d = cb.SelectedText; the problem is that in when i try to get the selected text in the SelectionChanged method i get this error "index and length must refer to a location within the string" when i try to get the selected in the SelectionChanged method, i simply get an empty string. whats the problem here?
-
ive had to write a coupple of classes to connect to data sources like databases in the last few weeks and ive found myself repeating a lot of code. im wondering, what methods/properties do you put in your abstract datasource connection class, and what do you put in the class that implements this abstract class? how do you structure a class that connects to a datasource so as to make it as reusable as possible
-
i want to be able to type a report into a text box, and then print it out , as it is in the text box. im using a rich textbox. how do i make sure the text box is the same size as an A4 sheet?
-
i am trying to enumerate through the primary keys in a table. i create an enumeration like so: System.Collections.IEnumerator e =ds.Tables[table.ToString()].PrimaryKey.GetEnumerator(); i then try to cycle through the items like so: while((e.MoveNext())&&( e.Current != null)) { if(e.Current.ToString() == key) { exists = true; break; } } now i know that there is one entry in the table, but as soon as i call the moveNext method, get an error telling me the ennumeration has already finished. what am i doing wrong?
-
i have to create a number of objects. they could be forms or any object really, but i want to know is how do i create a new object when a user clicks a button? the user could click the button many times, creating many objects, and i dont want to limit the user by only declaring a set number of objects
-
I want to have a window, that can contain many forms, and when they are minimized, they are placed at the bottom of the window, as in Microsoft access, how is this done?
-
im creating a crystal report. in the details section of the report designer i have placed some re-occouring data, eg product_bought, quantity, delivery_address store_name, has_product, price i want it to come out like this: Product quantity address product_bought, quantity, delivery_address product_bought, quantity, delivery_address product_bought, quantity, delivery_address product_bought, quantity, delivery_address store has item price store_name, has_product, price store_name, has_product, price store_name, has_product, price store_name, has_product, price instead, its comming out like this: Product quantity address product_bought, quantity, delivery_address store has item price store_name, has_product, price Product quantity address product_bought, quantity, delivery_address store has item price store_name, has_product, price Product quantity address product_bought, quantity, delivery_address store has item price store_name, has_product, price does anyone know how to solve this?
-
im not an expert at this, but i would use a web service. your client machine, which has to have IIS or some server running, could have a web service on it. the web service would have methods for returning the relivant data, and all connections to databases goes on in the background. because web services only pass strings (XML) across the web id say it would be pretty safe, but im sure there are other things you can do to increase the safety. a quick search on google will educate you on web services. they can be a huge topic, but it shouldnt be too difficult to do what you want to do here. best of luck
-
this is the way i find out if i have added a row to a dataset or not. there is a boolean value and after the row is added for the first time i set the value to false, so the next time the row is edited rather than added again. i can do this as the dataset is empty when i start, and i am only adding one row. im sure there is a more professional and better way to do this. can anyone tell me how they do it? if(workRecordCreated == false) { workRow = ds.Tables["work_details"].NewRow(); workRow["patient_id"] = guid; workRow["sitting"] = this.chkSit.Enabled; workRow["details"] = this.details.text; } else { ds.Tables["work_details"].Rows[ds.Tables["work_details"].Rows.Count-1].BeginEdit(); ds.Tables["work_details"].Rows[ds.Tables["work_details"].Rows.Count-1]["sitting"] = this.chkSit.Enabled; ds.Tables["work_details"].Rows[ds.Tables["work_details"].Rows.Count-1]["details"] = this.details.text; ds.Tables["work_details"].Rows[ds.Tables["work_details"].Rows.Count-1].EndEdit(); }
-
i keep having a concurrency violation when i try to update a row in my database. im adding the data via a form, and when the user clicks a button it is added to the database, but when i go back to the form to edit the data i get the concurrency violation. ive had it for a few days now and cant fix it. anyone have any ideas? heres where i add a row to the dataset. the recordcreated is a boolean to tell if the record needs to be created, or if it exists and needs to be edited instead if(recordCreated == true) { ds.Tables["Patient"].Rows[ds.Tables["Patient"].Rows.Count-1].BeginEdit(); ds.Tables["Patient"].Rows[ds.Tables["Patient"].Rows.Count-1]["first_name"] = this.txtFirstName.Text; ds.Tables["Patient"].Rows[ds.Tables["Patient"].Rows.Count-1]["sir_name"] = this.txtSirName.Text; ds.Tables["Patient"].Rows[ds.Tables["Patient"].Rows.Count-1]["dob"] = dateTimePicker1.Value.Day.ToString() + "/" + dateTimePicker1.Value.Month.ToString() + "/" + dateTimePicker1.Value.Year.ToString(); } if(recordCreated == false) { patientRow = this.ds.Tables["Patient"].NewRow(); patientRow["patient_id"] = guid; patientRow["first_name"] = this.txtFirstName.Text; patientRow["sir_name"] = this.txtSirName.Text; patientRow["dob"] = dateTimePicker1.Value.Day.ToString() + "/" + dateTimePicker1.Value.Month.ToString() + "/" + dateTimePicker1.Value.Year.ToString(); if(this.radMale.Checked == true) { patientRow["gender"] = "Male"; } else { patientRow["gender"] = "Female"; } ds.Tables["Patient"].Rows.Add(patientRow); recordCreated = true; } then when the user wants to commit the data to the database they click on a button: [code] this.dsF.UpdateChanges(ds); ds.AcceptChanges(); here is the code that commits the record to the database: public void UpdateChanges(DataSet dataset) { ds = dataset; DataSet changes = ds.GetChanges(DataRowState.Modified); foreach(DataTable tt in ds.Tables) { foreach (DataRow rr in tt.Rows) { if(rr.RowState == DataRowState.Deleted) { rr.Delete(); } } } try { this.daPatient.Update(ds,"Patient"); ds.AcceptChanges(); } catch (Exception exce) { System.Windows.Forms.MessageBox.Show(exce.Message); } }
-
if you just wrap up capicom in a .net wrapper using the runtime.interop namespace. that allows you to access windows api's by wrapping them. its a lot wasier than it sounds , just do a quick search on google, or use the msdn help. you just wrap up any methods from CAPICOM that you need and then you call them as regular methods. hope this helps
-
cant see cause for concurrency violation
fguihen replied to fguihen's topic in Database / XML / Reporting
its not. i generate the identity field in my form so the database has nothing to do with that. i can add and delete fine, its only when i try to update. stupid concurrency violation. thanks anyway -
ive never used crystal reports before. ive been messing with it today and created some basic basic reports with the report expert. i cant get it to do what i want though. i have 3 tables. the main table is the patient table it is linked to the patient_illness table via patient Id. there is an illnesses table that contains a list of illnesses and is linked to the patient_illness table via illness_id. i want the report to look like this: patient name, address, phone illness_name, details illness_name, details illness_name, details i cant get it to only select the data i want. it keeps displaying data like this: patient_name, address, phone, illness_name, illness_id, details patient_name, address, phone, illness_name, illness_id, details patient_name, address, phone, illness_name, illness_id, details patient_name, address, phone, illness_name, illness_id, details patient_name, address, phone, illness_name, illness_id, details also , rather than having to speicfy the select parameters when i actually design the report, how to i set it so that the report will be populated based on whatever patient_id i pick at runtime?
-
i have a tabcontrol , and each tab gathers some info the user thats regestering. when the user gets to the last tab page the collected data is passed to an object that sends the data to the database. everything is saved, but if i then go back and change some data one one of the tabs and try to update it i get a concurrency violation. i have update commands set up on all my data adapters so i dont see why the data that i saved cannot be updated when i submit the record again with slight changes. any ideas?im using c# and ms access database so there are no other users.its driving me nuts
-
visual studio is telling me that there is something wrong with my insert command for this data adapter and keeps throwing an error when i try to insert a row. can anyone see any problems with this code? the error simply says there is a problem with the insert into statement, but i cant see any problems. in the table, all fielts are text fields( as it is an access database) except the "text" field which is a yes/no field. this is the code to create the insert command for the data adapter: this.daContact.InsertCommand = conn.CreateCommand(); this.daContact.InsertCommand.CommandText = "insert into contact_details(patient_id,home_phone,mobile_phone,address,email,text) "+ "values(@patient_id,@home_phone,@mobile_phone,@address,@email,@text)"; this.daContact.InsertCommand.Parameters.Add("@patient_id",OleDbType.VarChar,50,"patient_id"); this.daContact.InsertCommand.Parameters.Add("@home_phone",OleDbType.VarChar,20,"home_phone"); this.daContact.InsertCommand.Parameters.Add("@mobile_phone",OleDbType.VarChar,20,"mobile_phone"); this.daContact.InsertCommand.Parameters.Add("@address",OleDbType.VarChar,120,"address"); this.daContact.InsertCommand.Parameters.Add("@email",OleDbType.VarChar,120,"email"); this.daContact.InsertCommand.Parameters.Add("@text",OleDbType.Boolean,1,"text"); here is the code that creates the row that will be inserted: contactRow = ds.Tables["contact_details"].NewRow(); contactRow["patient_id"] = guid; contactRow["home_phone"] = this.txthomePhone.Text; contactRow["mobile_phone"] = this.txtMobilePhone.Text; contactRow["address"] = this.txtAddress.Text; contactRow["email"] = this.txtEmail.Text; contactRow["text"] = this.chkText.Enabled; ds.Tables["contact_details"].Rows.Add(contactRow);
-
in a list box you can have a selected item, and a selected value. the items are shown in the list box and when you select one you can use the underlying selected value. eg. select "jimmy" in the list box, and the selected value property might be something like "cust_03". is this possible with cells in a datagrid?
-
got it sorted. just created a dataTable, insert the row into that , bound the grid to that table and refreshed it. i was looking at it the wrong way altogether. sorry for wasting your time
-
my usual validation technique is to use an if statement eg if(textbox1.text =="") { label1.text= "you must enter a username"; } this is fine for a small form, but i have a form with many controls to be validated and that seems a very crude way to validate. what is the "textbook" expert way of validating controls like text boxes , check boxes, raido buttons...
-
is there anyway for a windows form to know if it has already been visited, or is being viewed for the first time? you see, i have a form, on which i have a tab control. in the first tab i create a dataRow which takes data from the form and creates a customer. the user continues through various tabs until they enter all required data and save the record. however if the first tab is visited again for whatever reason, another row with the details is generated, and this causes an error as you cant have two identical users. any ideas around this?
-
kinda got it sorted. when i select a value in the list box, say "sony television", i want to place the id value for that product in the shopping list, something like "sy_tv_001". i bound the list box to the product table, the visible item is set to the product column and the value item is set to the product_ id_column. so when i select a product, i can pull the id associated with it from the value item property. sorry for not explaining properly. now, if only i knew how to add all this data pulled from list boxes and text boxes to a datagrid?thanks for your help
-
i dont think that will help. you see i want the user to see the product name, but if they select the product_ name, the product_ id is added to the shopping list. the user should never see the product_id though.its just a unique number