Interaction between the cell drop-down box of the datagridview

Source: Internet
Author: User
Step 2: first fill the first drop-down box with data in the load
            dgvCmbObligorType.DataSource = dtPayer;            dgvCmbObligorType.DisplayMember = "name";            dgvCmbObligorType.ValueMember = "id";
Step 2: Use the maid cellvaluechanged event to complete the Association
Private void maid (Object sender, maid e) {If (E. rowindex> = 0) {If (E. columnindex = 0) {If (datagridview1.rows [E. rowindex]. cells [0]. value! = NULL) {string id = maid [E. rowindex]. cells [0]. value. tostring (); datagridview1.rows [E. rowindex]. cells [0]. tag = ID; // obtain the owner according to the type if (ID = "2") // courier {string SQL = "Exec srmaster .. usp_getposter "; datatable dt = srwebclient. webClient. handler. dataclient. getdatatable (SQL); maid cell = maid [E. rowindex]. cells [1] as maid; cell. datasource = DT; cell. displaymember = "name"; cell. valuemember = "ID"; maid [E. rowindex]. cells [2]. value = "0";} else if (ID = "3") // site {string SQL = "select * From srmaster .. department where depcid in (800,801,802) order by name "; datatable dt = srwebclient. webClient. handler. dataclient. getdatatable (SQL); maid cell = maid [E. rowindex]. cells [1] As datagridviewcom Boboxcell; cell. datasource = DT; cell. displaymember = "name"; cell. valuemember = "ID"; maid [E. rowindex]. cells [2]. value = "0" ;}}} else if (E. columnindex = 1) {If (datagridview1.rows [E. rowindex]. cells [1]. value! = NULL) {string id = maid [E. rowindex]. cells [1]. value. tostring (); datagridview1.rows [E. rowindex]. cells [1]. tag = ID ;}}}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.