AllExperts > Experts 
Search      

VB.NET

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More VB.NET Answers
Question Library

Ask a question about VB.NET
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Brandon Drake
Expertise
I can answer questions regarding the Graphics object, file access, general optimization, printing (on paper), user controls, program mathematics, the registry, creating macros, processes, and fundamental or basic questions. I have made a few asp.net pages but I do not know the language extensively. I have not done much work with databases but I have created my own database systems.

Experience
I have been programming with visual basic for 6 years. In all I have written programs in about 8 programming languages, although, I only know about 3 well. I have written a few applications but mainly I like to write programs for fun.

 
   

You are here:  Experts > Computing/Technology > Basic > VB.NET > DataGridView with Combo

Topic: VB.NET



Expert: Brandon Drake
Date: 8/4/2006
Subject: DataGridView with Combo

Question
Hello Sir, Again Hari Here. Just i want to know how to get the left and top of the cell ( I think i will give the coordinate values in Pixels) and convert into the normal coordinates recognized by the combobox.I have tried with ur solution but the above problem is there. Pls send me code if possible.
Thanking you sir,

Regards
Hari Kumar

-------------------------

Followup To

Question -
Hi Sir, I am Hari Kumar.

I am facing one problem in Datagridview of VB.NET 2005.
Can u help me.

Problem 1:
I want to place a combobox control in the datagridview and able to control the navigation. When the Selection_Changed event is fired then only i want to display the combo in the corresponding cell ( not in all the rows of the same column, Only in the selected cell).Can u give me suggession as early as possible.In case if i use the builtin combo supported by DataGridView then I don't want to display the combo in more than one row.
Try to give the suggession with the  ToolBox combo (intrinsic).

I should able to set the datasource for that combo ( It is not a problem)
If u can able to send the code I am greateful to u.
I will be waiting for u r valuable reply.

Regards
Hari Kumar

Regards
Hari Kumar

Answer -
Hari Kumar,

I think what you will want to do is create a ComboBox outside of the DataGrid.  When the selection changes in the DataGrid you would have to move the ComboBox on top of the field it represents.  When the user selected an option in the ComboBox you would have to transfer their option to the DataGrid at the current record.

I have not worked much with DataGrids so this is the best solution I can think of.  I think you can get it to work though.



Good Luck,

Brandon Drake  

Answer
Hari Kumar,

I have never had to do this so I am not sure EXACTLY how to do it but I can give you some suggestions.

First, the "CurrentCell" property of the DataGridView obviously represents the current cell.  If you look at it's members there is one called "GetContentBounds" which gets a rectangle that represents the size of the control and possibly it's location.

Some other members that may be useful are the "FirstDisplayedCell" and GetCellDisplayRectangle members of the DataGridView control.

I could not write the code to determine the location of the cell, so you will have to be creative and use the information above to help you.

ONE WARNING--when you get something that works, make sure it works when the user scrolls in the DataGridView.



I hope this was helpful,

Brandon Drake

View Follow-Ups    Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.