but it's not a xml document and XmlDocument in that case sometimes doesn't do its job good so thats why I want to use reg. ex.
wi5nia
Posts
-
Regular expression problem -
Regular expression problemhi, I have a question about RE. Lets say I have this string:
Text
I get the "Text" by using this RE:MatchCollection m = Regex.Matches(wynik,@"\"">\s*(.+?)\s*");
I use MatchCollection beacuse I do it on a bigger file but for the ease of writing ths post I'm just an example of one line. Then on my collection I do a foreach and each Text is set as an Item Label in a dropDown list. But in the m regex I would also like to get the "comment" so then in my foreach loop I would be also able to assign it to the items Tag lets say. How can I achive this? -
Bindng and display problemthe second solution works like a charm :) many thanks
-
Bindng and display problemno, I just want to show a list of LastNames from the table, and if there is a NULL value for the LastName column in a given row then show for that row the value from the column Company
-
Bindng and display problemso what solution would suggest?
-
Bindng and display problemhi, I have this problem which I have been trying to solve for some time but with no result :( I have a table in sql server which consists of two columns: LastName and First name, and a result for a "select * from TestTable" is: Doe John NULL Mark Then a I have a piece of code in my WinForms application:
string connString = "server=.;database=Test;Integrated Security=SSPI;";
string sql = "select LastName, FirstName from TestTable";
SqlConnection conn = new SqlConnection(connString);
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
DataSet dataset1 = new DataSet();
da.Fill(dataset1, "TestTable");
DataTable dt = dataset1.Tables["TestTable"];listBox1.DataSource = dt; if (listBox1.DisplayMember.Length != 0) { listBox1.DisplayMember = "LastName"; } else { listBox1.DisplayMember = "FirstName"; } textBox1.DataBindings.Add("text", dt, "LastName"); textBox2.DataBindings.Add("text", dt, "FirstName");
and it works fine, when there is a NULL value in teh LastName column, in the listBox the FirstName is diplayed. The binding works ok Now when I alter the table and add another column (Company), the same sql query result looks like that: Doe John NULL Smith Mark NULL NULL NULL Microsoft Now when I make changes to the code to looke like this:
string connString = "server=.;database=Test;Integrated Security=SSPI;";
string sql = "select LastName, FirstName, Company from TestTable";
SqlConnection conn = new SqlConnection(connString);
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
DataSet dataset1 = new DataSet();
da.Fill(dataset1, "TestTable");
DataTable dt = dataset1.Tables["TestTable"];listBox1.DataSource = dt; if (listBox1.DisplayMember.Length != 0) { listBox1.DisplayMember = "LastName"; } else { listBox1.DisplayMember = "Company"; } textBox1.DataBindings.Add("text", dt, "LastName"); textBox2.DataBindings.Add("text", dt, "FirstName"); textBox3.DataBindings.Add("text", dt, "Company");
in the listBox I only get the Microsoft entry. The other entries are there but are not visible by the LastName but b
-
Update TextBox from second Formhi, I have and application which has 2 forms. The firts form has a textbox and a button which clicked opens a second form, which has just one button which clicked calls a method in the first form. The problem is, that the textbox doesn't update. There are no excpetion, when I set a break point the program goes into the line which updates the textbox but nothing happens. What is wrong?
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}public void add() { textBox1.Text = "Test"; } private void button1\_Click(object sender, EventArgs e) { Form2 f2 = new Form2(); f2.Show(); } }
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}private void button1\_Click(object sender, EventArgs e) { Form1 f1 = new Form1(); f1.add(); } }