32.5k views
2 votes
Create a project named ClassicBookSelector that contains a Form with a ListBox that lists at least five classic books that you think all educated people should have read. When the user places the mouse over the ListBox, display a Label that contains a general statement about the benefits of reading. The Label disappears when the user’s mouse leaves the ListBox area

User David U
by
5.3k points

1 Answer

4 votes

Answer:

See explaination

Step-by-step explanation:

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 BookListBox

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

string[] Book={"In Search of Lost Time","Ulysses","Don Quixote","The Great Gatsby","One Hundred Years of Solitude"};//declare variable book name

string[] Book_displayMessage = { "In Search of Lost Time by Marcel Proust", " Ulysses by James Joyce", "Don Quixote by Miguel de Cervantes", " The Great Gatsby by F. Scott Fitzgerald", "One Hundred Years of Solitude by Gabriel Garcia Marquez" };//declare variable Short dispay

string[] Book_BrienfSynpsis = { "Swann's Way, the first part of A la recherche de temps perdu, Marcel Proust's seven-part cycle, was published in 1913. In it, Proust introduces the themes that run through the entire work. ", "Ulysses chronicles the passage of Leopold Bloom through Dublin during an ordinary day, June 16, 1904.", "Alonso Quixano, a retired country gentleman in his fifties, lives in an unnamed section of La Mancha with his niece and a housekeeper.", "The novel chronicles an era that Fitzgerald himself dubbed the Jazz Age. ", "One of the 20th century's enduring works, One Hundred Years of Solitude is a widely beloved and acclaimed novel known throughout" };//declare variable Brienf synpsis

private void Form1_Load(object sender, EventArgs e)

{

lblBriefSynopsis.Text = "";//blank display textbox

lbldisplaymessage.Text="";//blank display textbox

for(int i=0;i<5;i++)

lbbook.Items.Add(Book[i]);//add book to listbox

}

private void lbbook_MouseHover(object sender, EventArgs e)

{

Point point = lbbook.PointToClient(Cursor.Position);

int index = lbbook.IndexFromPoint(point);

if (index < 0) return;

//Do any action with the item

lbldisplaymessage.Text = "Here is the Short things about it"+Environment.NewLine+Book_displayMessage[index];

}

private void lbbook_MouseLeave(object sender, EventArgs e)//mouse leave event here

{

lbldisplaymessage.Text = "";//here display message will blank textbox

}

private void lbbook_SelectedIndexChanged(object sender, EventArgs e)

{

}

private void lbbook_MouseClick(object sender, MouseEventArgs e)

{

lblBriefSynopsis.Text = Book_BrienfSynpsis[lbbook.SelectedIndex];//display click brienf Synposis

if (lbbook.SelectedIndex % 5 == 0)

this.BackColor=Color.Blue;

else if (lbbook.SelectedIndex % 5 == 1)

this.BackColor = Color.Red;

else if (lbbook.SelectedIndex % 5 == 2)

this.BackColor = Color.Purple;

else if (lbbook.SelectedIndex % 5 == 3)

this.BackColor = Color.Pink;

else if (lbbook.SelectedIndex % 5 == 4)

this.BackColor = Color.Orange;

}

}

}

User Shailesh Jaiswal
by
5.7k points