Hello, I would appreciate a little help with a program I'm making. It's basically an address book, consisting of a listBox that displays the people's name's, and text boxes which display their info... all of those are databound to a dataset, which is loaded from a SQL Server database when the program is loaded, and saved to it when the program exits. When creating the dataset, I add combined columns such as FullAddress which combines their address, city state and zip to be displayed together. I would rather do it like this then have separate display fields i.e. a separate textbox for first, middle, and last name because sometimes the middle name won't be added and it would look funny. But I need to keep all that info in its separate fields in the database for lookup purposes. Anyways, my problem is that when combining those fields when creating my dataset, I try to add new line characters so my fields are displayed like this...
Address
City, State Zip
But instead the newline characters are not being read and it all merges together
AddressCity,StateZip
Here is my code for combining the data columns
DataRow row = m_tempData.Tables["People"].NewRow();
row["FullAddress"] = tbAddress.Text + "\n" + tbCity.Text + ", " + cmbState.Text + "\t" + tbZip.Text;
The tab characters aren't getting either encoded or displayed correctly either. Is there another way for me to do this? I've looked all over and can't seem to find a solution, if anyone has any advice I would greatly appreciate it, I am stumped.
Thanks.
Nick
Loading
Sam HobbsPosted Aug 16, 2010, 1:32 PM
I used the term Master/Detail in a general manner; there is nothing specific in .Net or anywhere that is called that. It is a concept. It is the technique of showing a master such as an order and the details such as order items. When looking at orders, when a different order is viewed, all the details must be changed too. There would be a single order record showing that has multiple order item details.
Nick HoffmanPosted Aug 16, 2010, 10:37 AM
masterData.Tables["People"].Rows[i]["FullPhone"] = masterData.Tables["People"].Rows[i]["HomePhone"].ToString()
+ "\r\n" + masterData.Tables["People"].Rows[i]["CellPhone"].ToString()
+ "\r\n" + masterData.Tables["People"].Rows[i]["BusinessPhone"].ToString();
Unfortunately, it is still not displaying the new lines correctly. I'm not exactly sure, but I think I am using the master detail binding method, isn't it where multiple controls are bound to the same datasource? This is a function I have which I trigger when a new database is created...
public void BindData()
{
lbNames.DataBindings.Clear();
lbNames.DataSource = masterData;
lbNames.DisplayMember = "People.NameIndex";
tbName.DataBindings.Add("Text", masterData, "People.FullName");
tbAddress.DataBindings.Add("Text", masterData, "People.FullAddress");
tbPhone.DataBindings.Add("Text", masterData, "People.FullPhone");
tbNotes.DataBindings.Add("Text", masterData, "People.Notes");
tbEMail.DataBindings.Add("Text", masterData, "People.EMail");
}
It works really well and it displays the right information depending on which name is selected on the list box, I just can't get the FullAddress and FullPhone fields to display those new line characters. Seems like a simple problem but it is really holding me back.
Sam HobbsPosted Aug 14, 2010, 7:10 PM
As for tabs, there might be anoher property taht must be set for enabling tabs but I am not sure about that.
It would be easier to use a bound form that has data bound to it, but this web site I think does not have many articles about that. I wrote an introductory article but you should look for samples in the MSDN of master/detail data-bound forms.