Solved

populate comboBox with ColumnHeading from a DataViewGrid and allow editing

Posted on 2008-10-24
3
450 Views
Last Modified: 2008-10-24
Hi i was wondering if anyone could point me in the direction of, or explain to me some .NET C# code that will populate a comboBox with the ColumnHeading value of my DataGridView.

And to extend on that, code that will allow me to edit the comboBox having the changes renaming that particular column head

Im using Visual Studios C# .Net 3.0 i think
0
Comment
Question by:A_Kardas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
mokule earned 200 total points
ID: 22800050
To populate combobox You can do like this

            comboBox1.Items.Clear();
            foreach( DataGridViewColumn dgvc in dataGridView1.Columns)
                comboBox1.Items.Add(dgvc.HeaderText);
As to edit, You should explain, how it should work.
0
 

Author Comment

by:A_Kardas
ID: 22800720
ok that works perfectly as i wanted, now so i select Column1 for instance from the combobox. And i change that value to ID_Num, and click a button i have.

then the value in the coresponding column header becomes ID_Num

is it just going to be something as simple as

DataGridViewColumn = comboBox1.text     ? an i on the right track? i assume there is going to have to be an index or something so it knows which header to change.

sorry quite new to c# and programming in general, but looks like i have found a great place to read up and learn
0
 
LVL 17

Expert Comment

by:mokule
ID: 22800783
I wouldn't do this by editing comboBox.
It wouldn't be user friendly
I would rather do this by adding textbox for inputing new header text.
Moreover the code would be much simpler then

            dataGridView1.Columns[comboBox1.SelectedIndex].HeaderText = textBox1.Text;
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

617 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