Webbrowser control doenst show sites correctly - c#

I'm creating a custom internet browser in c# using the webbrowser control.
And it works i can load sites and browse around and all that.
But with some sites (with alot of pictures and such) he wont put everything in the right spot so i will get text blocks inside images and vice versa.
How do i solve this ?
My code :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication13
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
WB1.Navigate("http://nos.nl");
}
private void GoBtn_Click(object sender, EventArgs e)
{
if (AddRsBsr.Text.StartsWith("http://"))
{
WB1.Navigate(AddRsBsr.Text);
}
else if (AddRsBsr.Text.StartsWith("https://"))
{
WB1.Navigate(AddRsBsr.Text);
}
else
{
WB1.Navigate("http://www.googl.com/search?q=" + AddRsBsr.Text);
}
}
private void AddRsBsr_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return)
{
if (AddRsBsr.Text.StartsWith("http://"))
{
WB1.Navigate(AddRsBsr.Text);
}
else if (AddRsBsr.Text.StartsWith("https://"))
{
WB1.Navigate(AddRsBsr.Text);
}
else
{
WB1.Navigate("http://www.googl.com/search?q=" + AddRsBsr.Text);
}
}
}
private void BackBtn_Click(object sender, EventArgs e)
{
WB1.GoBack();
}
private void StopBtn_Click(object sender, EventArgs e)
{
WB1.Stop();
}
private void HomeBtn_Click(object sender, EventArgs e)
{
WB1.Navigate("http://google.nl");
}
}
}
Now i know my code isn't clean and all but im doing that right now while waiting and hoping for an answer.
Thanks !

The WebBrowser component defaults to rendering in ... IE7 mode.
To have it behave as IE10/11 you need to make the registry changed described here (FEATURE_BROWSER_EMULATION): http://msdn.microsoft.com/en-us/library/ie/ee330730(v=vs.85).aspx

Related

c# Metro framework - Previous and Next button to access another panels

I am developing this project "Profiling System" using MetroFramework and I've got this problem. If I click the next button I want my system to show the other panels where it has MetroTextboxes, MetroComboboxes, MetroCheckboxes and other tools of MetroFramework, But the panels does not appear.
I also want to try the UserControl just to slide it on the form but I don't know how. Please help.
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MetroFramework.Forms;
namespace TEST.cs
{
public partial class Form1 : MetroForm
{
List<Panel> listPanel = new List<Panel>();
int index;
public Form1()
{
InitializeComponent();
}
private void btnBack_Click(object sender, EventArgs e)
{
if (index > 0)
listPanel[--index].BringToFront();
}
private void btnNext_Click(object sender, EventArgs e)
{
if (index < listPanel.Count - 1)
listPanel[++index].BringToFront();
}
private void Form1_Load(object sender, EventArgs e)
{
listPanel.Add(metroPanel1);
listPanel.Add(metroPanel2);
listPanel.Add(metroPanel3);
listPanel[index].BringToFront();
}
}
}

C# Strongly typed dataset validation approach

I am trying to "learn" C# and building my 1st database driven data entry application. I am coming from Oracle development, hence wondering whether am doing few things right, as most of the examples I could find are dealing with datasets derived using SQL
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace lSystem
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void l_PEOPLEBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
if ((string.IsNullOrWhiteSpace(fIRST_NAMETextBox.Text) || (string.IsNullOrWhiteSpace(cIVIL_IDTextBox.Text) ||
(string.IsNullOrWhiteSpace(tELEPHONE_NUMBERTextbox.Text)))))
{
MessageBox.Show("Error, one of the mandatory columns are not filled up");
return;
}
try
{
this.Validate();
this.pERSON_IDTextBox.Text = this.l_PEOPLETableAdapter.ScalarQuery().ToString();
this.l_PEOPLEBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.uNUDataSet);
}
catch (Exception ex)
{
MessageBox.Show("Exception happened, original message: " + ex.Message);
}
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'uNUDataSet.L_PEOPLE' table. You can move, or remove it, as needed.
this.l_PEOPLETableAdapter.Fill(this.uNUDataSet.L_PEOPLE);
// this.fIRST_NAMETextBox.Focus();
this.ActiveControl = this.fIRST_NAMETextBox;
}
private void sByName_Click(object sender, EventArgs e)
{
this.l_PEOPLETableAdapter.FillByNAME(this.uNUDataSet.L_PEOPLE, this.sByNameText.Text);
}
private void fIRST_NAMETextBox_Validated(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(fIRST_NAMETextBox.Text))
{
eNROLL_errorprovider.SetError(fIRST_NAMETextBox, "Name required");
fIRST_NAMETextBox.Focus();
}
}
private void cIVIL_IDTextBox_Validated(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(cIVIL_IDTextBox.Text))
{
eNROLL_errorprovider.SetError(cIVIL_IDTextBox, "Civil ID Number required");
cIVIL_IDTextBox.Focus();
}
}
private void tELEPHONE_NUMBERTextbox_Validated(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(tELEPHONE_NUMBERTextbox.Text))
{
eNROLL_errorprovider.SetError(tELEPHONE_NUMBERTextbox, "Telephone Number required");
tELEPHONE_NUMBERTextbox.Focus();
}
else
{
eNROLL_errorprovider.Clear();
}
}
}
}
What I am trying to do with the above piece of code is, unless the user enters first name, civil id number and supply the telephone number, the form shouldn't submit the data. For the person id, I am using a sequence, called through a scalar query attached to the table adaptor.
While I click the binding navigator save button, what should execute in order to fire the validation events attached with the text columns so that the error provider will get activated?
You need to register the event like the code below
public Form1()
{
InitializeComponent();
tELEPHONE_NUMBERTextbox.Validated += new EventHandler(tELEPHONE_NUMBERTextbox_Validated);
}
private void tELEPHONE_NUMBERTextbox_Validated(object sender, EventArgs e)
{
}

skype4comlib Create List of Friends

I'm trying to grab a list of all of my Skype friends who are online and put it into my listbox named lst1.
I'm also trying to make my tool answer to some commands like if some one sends !news to me it messages them a text that I've set in the code.
This is what I've tried so far, I'm just playing around with the code to learn how to use skype4comlib.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MetroFramework;
using MetroFramework.Forms;
using MetroFramework.Components;
using SKYPE4COMLib;
using System.Threading;
namespace betaskypetool
{
public partial class Form1 : MetroForm
{
#region Definitions
Skype Merk = new Skype();
private int count = 1;
#endregion
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void metroButton1_Click(object sender, EventArgs e)
{
try
{
this.Merk.Attach(5, true);
MessageBox.Show("You are now connected enjoy!", "Tutorial Skype Tool!");
}
catch (Exception)
{
MessageBox.Show("Failed To Connect?\n Be Sure Skype Is Open!", "Tutorial Skype Tool!");
}
}
private void metroButton2_Click(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusOnline;
}
private void metroButton3_Click(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusDoNotDisturb;
}
private void metroButton4_Click(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusAway;
}
private void metroButton5_Click(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusInvisible;
}
private void metroButton6_Click(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusOffline;
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if(checkBox1.Checked == true)
{
timer1.Start();
}
else
{
timer1.Stop();
}
}
private void timer1_Tick(object sender, EventArgs e)
{
this.Merk.CurrentUserStatus = TUserStatus.cusOnline;
Thread.Sleep(20);
this.Merk.CurrentUserStatus = TUserStatus.cusAway;
Thread.Sleep(20);
this.Merk.CurrentUserStatus = TUserStatus.cusDoNotDisturb;
Thread.Sleep(20);
this.Merk.CurrentUserStatus = TUserStatus.cusInvisible;
Thread.Sleep(20);
}
private void metroButton7_Click(object sender, EventArgs e)
{
foreach(User spamall in Merk.Friends)
{
Merk.SendMessage(spamall.Handle, "Haiiiii" + spamall.FullName + ",\n" + richTextBox1.Text + "\n\n(cash) Sent From Merk's Tutorial Tool! (cash)");
}
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
I hope you understand my question and can help me out with what I need to do to add those 2 features to my project
You can get a collection of your online friends like this:
var onlineFriends = Merk.Friends.Cast<User>().Where(u => u.OnlineStatus == TOnlineStatus.olsOnline);
After this it's easy to put them in a ListBox.
WPF example:
foreach (var friend in onlineFriends)
{
MyListBox.Items.Add(friend.FullName);
}
That said, I'm not sure if it's worth to spend a lot of time learning it, because according to this blog post, Microsoft doesn't really support skype4comlib anymore.
https://support.skype.com/en/faq/FA12384/how-does-my-3rd-party-application-work-with-skype-and-how-will-changes-to-skype-impact-my-3rd-party-application
As communicated in this blog post, due to technology improvements we are making to the Skype experience, some features of the API will stop working with Skype for desktop. For example, delivery of chat messages using the API will cease to work.
For example, I'm not able to send a message using the library anymore.
PS.: I'm using Skype 7.17.0.106

messagebox.show error/ no overload for method 'show' takes 1 arguments

I'm trying to show a MessageBox but i'm getting the error:
no overload for method 'show' takes 1 arguments.
I cant seem to find a solution in any forum (stackoverflow,msdn...) and I have tried everything that has been suggested. What am I missing?
Any help is appreciated.
BTW. I'm new to windows forms and c# in general but I have written this from a tutorial and it should work.
This is the complete code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using NetworksApi.TCP.CLIENT;
using System.IO;
namespace AdvancedClientChat
{
public partial class Form1 : Form
{
Client client;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void btnConnect_Click(object sender, EventArgs e)
{
if (textBoxIP.Text !="" && textBoxName.Text !="" && textBoxPort.Text !="")
{
client = new Client();
client.ClientName = textBoxName.Text;
client.ServerIp = textBoxIP.Text;
client.ServerPort = textBoxPort.Text;
}
else
{
MessageBox.Show("You must fill all the boxes");
}
}
private void btnSend_Click(object sender, EventArgs e)
{
}
private void MessageBox_KeyDown(object sender, KeyEventArgs e)
{
}
}
}
It looks like you have a control named MessageBox which is causing your problems. Either rename the control, or you will have to specify the MessageBox class with its full namespace, System.Windows.Forms.MessageBox.Show("myMessage");
private void btnConnect_Click(object sender, EventArgs e)
{
if (textBoxIP.Text !="" && textBoxName.Text !="" && textBoxPort.Text !="")
{
client = new Client();
client.ClientName = textBoxName.Text;
client.ServerIp = textBoxIP.Text;
client.ServerPort = textBoxPort.Text;
}
else
{
System.Windows.Forms.MessageBox.Show("You must fill all the boxes");
}
}

How to use a query in C# (not web)?

I have created a database in microsoft office access. In form1.cs i added a DataGridView with the source from the database created. In tableDataSet.xsd/tabelAdapter i created a new query with 3 parameters which i use to insert the data in the database ( Name, Password, Age) . how can i use this query with that 3 parameters from 3 different textbox?
PS: i use only Windows Form Application, no asp.net or etc.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace lucian
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'jucatoriDataSet.jucator' table. You can move, or remove it, as needed.
this.jucatorTableAdapter.Fill(this.jucatoriDataSet.jucator);
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void adaugareToolStripButton_Click(object sender, EventArgs e)
{
try
{
this.jucatorTableAdapter.Fill(this.jucatoriDataSet.jucator);
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
Take a look at that article http://msdn.microsoft.com/en-us/magazine/cc163709.aspx
Basically you need to learn about ADO.NET :)

Categories

Resources