Click here to Skip to main content
16,015,594 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I want to know how to use Arrow Keys with FlowLayoutPanel Data.
I have populated some values in FlowLayoutPanel with Images inside a Panel. I am not able to use Arrow Keys to Image selection change.

Please Provide me any demo about this.
Posted
Comments
BillWoodruff 5-Feb-16 4:22am    
Is it your goal here ... after you have populated the FlowLayoutPanel with various images ... that you wish to click on one of the images, and then, when the user presses an arrow key, cycle through other images.

In other words the contents of each "virtual cell" in the FlowLayoutTable is actually a series of images (using an ImageList control, for example) ... so, the right-arrow key might go the last in the series ... the left-arrow key to the first in the series; the up- and down- arrow keys move ahead, or back, in the series ?

Or, is your goal to use the arrow keys to move around from Image to Image (i.e., each "virtual cell" contains one Image) ?

This can be done. What have you tried so far ?

fyi: I strongly advise you to switch to using the 'TableLayoutPanel; it's facilities are much easier to work with.

1 solution

There is no demo because the FlowLayoutPanel is not a real control. Its "cells" are not selectable and there are no keyboard events. It's an extension to other controls to modify how they position themselves on the form. The same thing is true for the TableLayoutPanel.
 
Share this answer
 
Comments
Abdul Amin Khan 5-Feb-16 1:10am    
Dear Dave,

Have you any alternative of that. There is any control in C# winForms that show images like Grid/Tiles in Forms. I need it.
Dave Kreskowiak 5-Feb-16 9:55am    
That depends on exactly what you're doing. Your original description doesn't give enough detail to make a recommendation.
BillWoodruff 5-Feb-16 4:19am    
My vote of #1. This is an absurd description of what the TableLayout Panel is, and what you can do with it; only slightly less absurd a description of 'FlowLayout Panel.
Dave Kreskowiak 5-Feb-16 9:54am    
What's so "absured" about it? It's technically accurate. They're both extension controls, albeit based on a Panel, that modify the behavior of other controls.
Abdul Amin Khan 7-Feb-16 3:12am    
//Designer Form
partial class Form1
{
///
/// Required designer variable.
///

private System.ComponentModel.IContainer components = null;

///
/// Clean up any resources being used.
///

/// <param name="disposing">true if managed resources should be disposed; otherwise,

false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.BrowseMultipleButton = new System.Windows.Forms.Button();
this.PhotoGallary = new System.Windows.Forms.FlowLayoutPanel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.treeView1 = new System.Windows.Forms.TreeView();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// openFileDialog1
//
this.openFileDialog1.FileName = "openFileDialog1";
//
// BrowseMultipleButton
//
this.BrowseMultipleButton.Location = new System.Drawing.Point(314, 4);
this.BrowseMultipleButton.Name = "BrowseMultipleButton";
this.BrowseMultipleButton.Size = new System.Drawing.Size(130, 27);
this.BrowseMultipleButton.TabIndex = 2;
this.BrowseMultipleButton.Text = "Browse Multiple Files";
this.BrowseMultipleButton.UseVisualStyleBackColor = true;
this.BrowseMultipleButton.Click += new System.EventHandler

(this.BrowseMultipleButton_Click);
//
// PhotoGallary
//
this.PhotoGallary.AllowDrop = true;
this.PhotoGallary.AutoScroll = true;
this.PhotoGallary.BackColor = System.Drawing.Color.Black;
this.PhotoGallary.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.PhotoGallary.Location = new System.Drawing.Point(274, 35);
this.PhotoGallary.Margin = new System.Windows.Forms.Padding(1);
this.PhotoGallary.Name = "PhotoGallary";
this.PhotoGallary.Size = new System.Drawing.Size(600, 473);
this.PhotoGallary.TabIndex = 3;
this.PhotoGallary.MouseEnter += new System.EventHandler

(this.PhotoGallary_MouseEnter);
this.PhotoGallary.PreviewKeyDown += new

System.Windows.Forms.PreviewKeyDownEventHandler(this.PhotoGallary_PreviewKeyDown);
//
// pictureBox1
//
this.pictureBox1.AllowDrop = true;
this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox1.Location = new System.Drawing.Point(878, 43);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Padding = new System.Windows.Forms.Padding(5);
this.pictureBox1.Size = new System.Drawing.Size(304, 161);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 4;
this.pictureBox1.TabStop = false;
this.pictureBox1.DragDrop += new System.Windows.Forms.DragEventHandler

(this.pictureBox1_DragDrop);
this.pictureBox1.DragEnter += new System.Windows.Forms.DragEventHandler

(this.pictureBox1_DragEnter);
//
// treeView1
//
this.treeView1.Font = new System.Drawing.Font("Bookman Old Styl

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900