Solved

Creating a custom grid

Posted on 2004-09-14
3
176 Views
Last Modified: 2010-04-15
Hi,

I am quite new to C# and need a bit of help :)

I need to create a control that simulates a grid  (it doesn't have to be a grid!) with 3 fields.
Field 1: Should hold a 'custom control', for which events can be fired. (I need the click event)
Field 2: Should hold a fixed value, that can't be changed.
Field 3: Should hold a text value, that can be changed. (Renamed)

I'm a bit stuck at this stage (don't really know where to start), and any help would be appreciated.

Thanx,
AA
0
Comment
Question by:april_angel
3 Comments
 
LVL 6

Accepted Solution

by:
Svetlin_Panayotov earned 500 total points
ID: 12055697
CodeProject - http://www.codeproject.com/cs/miscctrl/csharpgridcontrol.asp
I found this really cool grid - and have been using it for some time.I'm not quiet sure if it'll help - the source is a bit complicated.
0
 

Author Comment

by:april_angel
ID: 12245885
Hi,

Apologies for not answering the question. I had a look at Svetlin comment, and it does not really solved my problem.
I have found the answer though:
All I had to do was create all my controls progammatically and place it into a container (panel). I didn't know that by creating the controls like this I would be able to enable the events, and the fact that control arrays are not available in C# didn't make it easier, either.   Below follows an excerpt of the code I've used. What the application code does it runs a loop that calls the procedure below and keeps adding the controls to the containing panel.

private void CreateGridEntry(int Index, string DisplayText)
{
      //Declare and Initialise
      Button btnLayerValueDisplayColor = new Button();
      Label lblLayerValueDisplayName = new Label();                  
      TextBox txtLayerValueEntry = new TextBox();      


      //Button
      btnLayerValueDisplayColor.Name = "btnValueDisplayName_" + Index.ToString();
      btnLayerValueDisplayColor.Click += new System.EventHandler(this.ChangeSymbolEvent);
      btnLayerValueDisplayColor.Height = 24;
      btnLayerValueDisplayColor.Top = (btnLayerValueDisplayColor.Height + 6)* Index
      btnLayerValueDisplayColor.Left = 8 ;
      btnLayerValueDisplayColor.Width = 24;                  
      btnLayerValueDisplayColor.Tag =Index.ToString();
      btnLayerValueDisplayColor.Image = Image.FromFile(Application.StartupPath + @"\Images\Painter.bmp");
      pnlSymbolSet.Controls.Add(btnLayerValueDisplayColor);
      
      //Label
      lblLayerValueDisplayName.Name = "lblValueDisplayName_" + Index.ToString();
      lblLayerValueDisplayName.Top = btnLayerValueDisplayColor.Top;
      lblLayerValueDisplayName.Left = btnLayerValueDisplayColor.Left + btnLayerValueDisplayColor.Width;
      lblLayerValueDisplayName.Text =  DisplayText;
      lblLayerValueDisplayName.Width = 190;
      lblLayerValueDisplayName.Height = btnLayerValueDisplayColor.Height;
      lblLayerValueDisplayName.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
      pnlSymbolSet.Controls.Add(lblLayerValueDisplayName);
}

Again, I apologise for not replying sooner.

Thanx in any case,
AA
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
WPF issue with Trigger 2 66
Adding WebGrid Checkbox Column checked by default 3 26
send mail from app.net 8 28
Image(2) 3 22
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now