Fenrir() 52 Newbie Poster

Do you mean that you want the first half to be centered on top and then the second part below it to be left alinged?

this is a very simple example you can test for yourself. If indeed i'm understanding you correctly

richTextBox1.AppendText("Header");
richTextBox1.SelectionAlignment = HorizontalAlignment.Center;
richTextBox1.AppendText(System.Environment.NewLine);
richTextBox1.AppendText("First Line");
richTextBox1.SelectionAlignment = HorizontalAlignment.Left;
Fenrir() 52 Newbie Poster

Try this. (c as CheckedListBox).CheckedItems.Count

Fenrir() 52 Newbie Poster

Can't quite remember where i found this but it works like a charm.

Add the following method in your application

public IEnumerable<T> FindControls<T>(Control control) where T : Control
{
  var controls = control.Controls.Cast<Control>();

  return controls.SelectMany(ctrl => FindControls<T>(ctrl))
                                     .Concat(controls)
                                     .Where(c => c.GetType() == typeof(T)).Cast<T>();
}

Then you can call it as followed.

var t = FindControls<CheckedListBox>(this);

foreach(Control c in t)
{
  MessageBox.Show(c.Name);
}

This will for example bring back all the checklistboxes on the control you called the method with. Above the form is being passed in. this

ddanbe commented: Nice! +15
Fenrir() 52 Newbie Poster

You should be able to create a user control for this in the WPF side and then use an element host in your winforms application. Here is a nice link describing it Click Here. You'll probably need to take the plunge and sharpen up on your WPF though. even if it's just a little bit

Fenrir() 52 Newbie Poster

There might be a better way but i'm lazy so i loaded the image into the picturebox it ads the size mode and then i save and load the image from a temporary directory. Click Here this ensures that the sizemode is applied to the image

--Edit
this might be a better way actually Click Here you can resize the image on the fly in your base64 method and then save it to the stream

dhatsah commented: Thanks the second method was perfect. +0
Fenrir() 52 Newbie Poster

You mean If (Textbox2.Text == "") ? you should be able to add that in the text changed event

Fenrir() 52 Newbie Poster

Try adding a breakpoint on row 10 and checking the value of your RowFilter by hovering on it a small magnifying glass should appear. Click it and paste the text into SQL server and add the SELECT * FROM TableName WHERE and check the results.

Alternatively you can try the following line of code which reads much simpler.

(dataGridView1.DataSource as DataTable).DefaultView.RowFilter = string.Format("CashAccRef LIKE '%{0}%' OR CashName LIKE '%{1}%'", textBox2.Text,textbox2.Text);

When stepping your code make sure that none of the datasets you're using still have a previous row filter applied when running the application for all IF scenarios.

Fenrir() 52 Newbie Poster

I've had this in the past and i felt pretty stupid but there wasn't enough space to actually create the file which will probably not be the case seeing as the file in question is so small (But still). Another issue i've come accross was permissions. Try uploading the file without code via windows explorer or another 3rd party application and see if that works.

Fenrir() 52 Newbie Poster

Can you post the exact error you are receiving

Fenrir() 52 Newbie Poster

What exactly do you have in your checklistbox? If you want an Insert Statement to run for each item in your checklistbox then you have to assign your parameters and execute inside your for (int a = 0; a < CheckBoxList1.Items.Count - 1; a++)

Fenrir() 52 Newbie Poster

Can you please paste the exact error you are receiving

Fenrir() 52 Newbie Poster

The variable datum is only assigned inside your try{} so that's where you need to do your comparisons

Fenrir() 52 Newbie Poster

Glad we could be of assistance.

Fenrir() 52 Newbie Poster

Sorry i was assuming you were using MS SQL here is the C# version

string test = "41521.880937(04.09.13 21:08:33)";
DateTime date = Convert.ToDateTime(test.Substring(test.IndexOf("(")+1, (test.IndexOf(")") - test.IndexOf("(")-1)).Replace(".","-"));

output : 4/9/2013 9:08:33 PM

Fenrir() 52 Newbie Poster

So you're looking for something like this?

DECLARE @Val VARCHAR(100) = '41521.880937(04.09.13 21:08:33)'
SELECT CAST(REPLACE(SUBSTRING(@Val,CHARINDEX('(',@Val,0)+1,(CHARINDEX(')',@Val,0)-CHARINDEX('(',@Val,0)-1)),'.','-') AS DATETIME) AS Date

Wrote this very quickly so feel free to play around with it this code assumes the date will be in the above mentioned format.

Fenrir() 52 Newbie Poster

Could you please post your question on a new thread seeing as you've marked this one as solved.

Fenrir() 52 Newbie Poster

When are you reading the data from the files? when a user inputs data you want to go get values from the file and compare?

Fenrir() 52 Newbie Poster

If this is the error you are still getting 'Incorrect syntax near '@Numberpassengers'.' then remember INSERT INTO(Columns) VALUES (Values) Remember your Parenthesis ( ) ( ) you are missing the last one for VALUES you have VALUES (... add an ")"

Fenrir() 52 Newbie Poster

Are you still getting the same exception? Did you add the ) to the following line

"insert into BookDetails(CarName,Source,Destination,Date,FromAddress,ToAddress,Time,Numberpassengers)VALUES(@CarName,@Source,@Destination,@Date,@FromAddress,@ToAddress,@Time,@Numberpassengers)"  <----
Fenrir() 52 Newbie Poster

An easy way to see exactly what's going wrong is inserting a breakpoint on line 29 on the above code extract. Then investigate the value of the cmd query by using the text visualizer. Copy the code from there directly into sql and parsing it to sql standards. Run the query and see where the syntax error is. but just for the fun of it you're missing a ")" at the end of your values statement.

Fenrir() 52 Newbie Poster

I assume you're reading the data into an array. You know that your date will be in column 1 and your Summe would be in your last column so on each readline of the file you only retrieve these two values based on their index in the array.

Fenrir() 52 Newbie Poster

What is the error you are getting?

Fenrir() 52 Newbie Poster

Are you manually populating your grid? Or did you specify it in your properties?

Fenrir() 52 Newbie Poster

myConn.Open(); add a breakpoint here and step your code and see on exactly what line it throws an exception

Fenrir() 52 Newbie Poster

You should be able to add the key with the corresponding progressbar to something like a dictionary Dictionary<Char,ProgressBar> and then on keypress check your dictionary and retrieve the relevant entry

Fenrir() 52 Newbie Poster

So you're getting Message - > Username? Sorry i don't quite understand your question. Please post the code aswell

Fenrir() 52 Newbie Poster

Is it always going to be in this &nbsp;hlo<div><br></div> Format? and only the hlo part changes? if that's the case there are numerous methods you can use just off the top of my head something like this

string test = "&nbsp;hlo<div><br></div>";
test = test.Substring(test.IndexOf(";")+1, test.IndexOf("<") - test.IndexOf(";")-1);
Fenrir() 52 Newbie Poster

MySqlCommand SelectCommand = new MySqlCommand("select * from livestream.views where video_id ='" + videoid + "' and ACTIVE=1 ", myConn); when you insert a breakpoint on this line. What is the value of the videoid ? and when you run this directly in SQL how many values are returned?

Try this when you step your code hover over the select command and use the text visualizer and copy the code directly into SQL

Fenrir() 52 Newbie Poster

Please post your code. How are you declaring the array?

Fenrir() 52 Newbie Poster

When you insert a breakpoint you can step your code. Highlight and rightclick the combobox you can then inspect the Value and Display members and check if they are correct.

Fenrir() 52 Newbie Poster

string videoID = myReader.GetString("video_id"); this sould be in your combobox you select from by my understanding. Is that the physical ID? If you select from views based on the video ID then you should get the people who viewed that video. Otherwise when you populate the Video ID combobox and you're displaying the video name you will need to Set the value member and display member

Fenrir() 52 Newbie Poster

SELECT u_id FROM Views WHERE video_id = "+YourComboBox.SelectedItem.ToString()+"

Fenrir() 52 Newbie Poster

You have the video ID so i assume your second query is just a standard select aswell. So when you're selecting you can just initialize another reader and loop through the User Id's you return. So as John suggested you can then create a list<string> outside your loop and add the items to it. Once your DataReader (While) has finished and the list is populated you can then assing the list to the RichTextbox as follows RichTextBox.Lines = myList.ToArray();

So it should look something like this

//Declare your list

List<string> list = new List<string>

while (myReader.Read()) 
{
string userID = myReader.GetString("user_id");
list.add(UserID);
}

RichTextBox.Lines = list.ToArray();

I hope this helps you

Fenrir() 52 Newbie Poster

Am i getting this right : you want the "video_id" returned by your reader so you can pass it into another query to retrieve the values? If that is the case you need to declare the variable outside your method so you can use it in another. So string videoID; needs to be moved outside the method and only assigned in the comboBox1_SelectedIndexChanged as follows videoID = myReader.GetString("video_id"); and then you can use it in your other query.

Fenrir() 52 Newbie Poster

Please post your code that you use to populate your combobox with titles.

Fenrir() 52 Newbie Poster

I think it will be better to test your query in SQL first. You can do the JOIN logic in SQL and merely pass the string to SQL via a SQLCommand. Reading your previous comments led me to the conclusion that johnrosswrock's previous comment is what you need. You want to retrieve all the users that viewed the selected video? Is that correct?

Fenrir() 52 Newbie Poster

Try disposing the attachment before your delete statement.

data.Dispose();

Fenrir() 52 Newbie Poster

How are you sending the email? If the objects used to send the email are properly disposed in your code then you should have no problem deleteing the PDF

Fenrir() 52 Newbie Poster

When you step the code and hover on gridTest.Visibility what does the current visibility show?

Fenrir() 52 Newbie Poster

It means that your application is trying to login to sql and retrieve the data. but it's being prompted for a username and password. You need to specify this in your connection string for cn.

Fenrir() 52 Newbie Poster

Is this what you mean?

if (MessageBox.Show("record exist. do you want to continue?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
  //Do Something
}
else
{
  //Do something else
}
Fenrir() 52 Newbie Poster

You will to decide when to call the check method or you might need to use a timer and assign the appropriate interval.

Fenrir() 52 Newbie Poster

Have you tried anything yet? This might point you in the right direction Click Here You need to loop all the tabpages and their richTextBoxes. If you want to change only "int" and "2" in the string "int a = 2" you will probably need to use something like regex to only find "int" preceding an "a" and a "2" succeeding an "=" character.

Fenrir() 52 Newbie Poster

You can try this

        private void button2_Click(object sender, EventArgs e)
        {
            foreach (RichTextBox richtext in tabControl1.TabPages[tabControl1.SelectedIndex].Controls)
            {
                MessageBox.Show(richtext.Text);
            }
        }

Or just change your code to

            int tabNum = tabControl1.SelectedIndex + 1;
            RichTextBox textBox = tabControl1.SelectedTab.Controls.Find(("New file " + tabNum), true).FirstOrDefault() as RichTextBox;
            //textBox.Focus();
            MessageBox.Show(textBox.Text);
            //textBox.Focus();

Such a small thing that's causing all the frustration

Fenrir() 52 Newbie Poster

Sorry if this reply is a bit late but i was curious. I replicated the problem as you are only replacing a partial match. Check this out for a simple and effective solution Click Here

Fenrir() 52 Newbie Poster

Click Here

And this.

Fenrir() 52 Newbie Poster

You can use a switch statement.

Click Here

Fenrir() 52 Newbie Poster

try inserting a breakpoint on that line.

Breakpoint-> if (textboxusername.Text == Uname && textboxpwd.Text == PWord)

Then check the value of textboxusername.Text and Uname by right clicking and adding a quick watch. You can then copy the two values over to something like notepad and see if there are any significant differences.

Fenrir() 52 Newbie Poster

Click Here

Try this and take it from there.

Fenrir() 52 Newbie Poster

I agree.. Make sure you're focussed on the correct datagridview. If this is the case just do a simple test by removing the grid on tab 1 and tab 3 and check if it adds to the grid on tab 2. Crude but effective.